If you wake up during REM sleep, you easily detail pieces and bits of dreams/nightmares REM sleep takes place when your pons in the brain. The pons shuts off neurons in the spinal cord to temporarily paralyse the limbs. This is because youi don't act out your dream(s)/nightmare(s) Some believe that dreams are the Cortex's attempt to interpret and put meanings to new information and experiences.
For the one's who don't know the science terms that are used I have listed them down below.
REM: REM stands for rapid eye movement that occurs when dreaming while asleep.
Pons: part of the brain thats role is to manage regulating sleep, arousal and breathing and coordinating some muscle movements.
Most of this is in my own words. The sources that are use were the guidelines from
If you have any questions feel free to inbox me :D