Have you had an episode of sleep paralysis, where you can’t move while sleeping but are aware of your surroundings?
In a sleep paralysis dream, you see and feel yourself in your bed and the room around you looks normal, but you cannot move your body. In short, it feels like your mind wakes up before your body does.
I personally agree with the theory that this is a situation where your brain is protecting you from sleep walking. The National Sleep Foundation classifies sleep paralysis as parasomnia. WebMD provides a list of factors that may contribute to this issue.