Hey, found some creepy shit
here that might help explain about your situation:
Sleep Paralysis
As you fall asleep, several things happen. First, your conscious mind is set to low-level functioning. Next, your body is immobilized so that you can dream of doing things like running, without actually running into your bedroom wall... Then, your brain cycles in and out of REM. Occasionally, your conscious mind wakes up, but forgets to include other parts of your brain, usually just seconds before the REM is phased completely out. The result is that for the next few moments, you get to watch the dream, or rather nightmare in most cases, played out as a vivid hallucination right before your very much awakened eyes.
Oh, and that part about you being immobilized? That's still there, hence the "paralysis" half of "sleep paralysis." Not only do get to watch the demonized spider-crabs on your ceiling eat a tiny kitten just above your immobile body, you are completely helpless to do anything about it when they come for you.
Or it could be a case of
exploding head syndrome in the middle of your sleep.
I once dreamt I was peeing, but IRL, I wasn't for some reason. Then in the same dream, after peeing, I washed my hands (still nothing) then spat on the toilet a mouthful of phlegm. I suddenly woke to the grossing smell of morning spit plus phlegm. No pee, no water, but I just spat on the pillow. Weird, because usually you wake up the moment you pee in your dreams for a reason I'm sure everybody knows.