You were entering sleep paralysis. We enter it every night unconsciously to stop ourselves from actin out our dreams. You probably woke up from the excitement of knowing that you're dreaming. Just stay calm and touch everything around you to stabilize, along with using all of your other senses before going off.