Not being able to move, while having a nightmare without being asleep, is referred to as night terrors. It is an actual thing.
Danish folklore says this is because a mara is riding on top of your torso. Logically, this obviously is meant as a defence system, in case the mara’s sleeping victim wakes up while she’s busy spreading nightmares.