How is it possible? Well, you have to wake up during it when your brain is active in it. This usally happens in REM dreaming. Your brain remembers it and stuff. Dreams could be just us remembering things, that couldhelp us in life, or the brain trying to understand random neuron shocks in it, turning it into a dream. I could go on and on and on...