The brain disconnect the spine, when you are in the most "dreamy" sleep. Sometimes this dont work the right way, and your body move. Happens to everyone once in a while. If the brain didnt disconnect our body, we would do lots of crazy moves in while sleeping. It can also work the other way around, which is more creepy. You are in a state of sleep, but the mind wake up.. "half asleep, half asleep" but you cant move a finger! You belive you are screeming, but you actually dont make a sound. Then suddenly is back full awake with a BANG! Scary but cool if you know how to react.
There are ways to learn how to get to this type of sleep. The mind is half awake, but the spine are disconnected with the brain. This also the way to do "out of body experiences"
that has happened too me a couple of times, you are awake and you want to move but you cant, so fucking horrible.