When you dream, it's your mind running through everything that it has seen, felt, or been through physically or emotionally. It is the way your mind 'sleeps'. We dream every night whether we remember it or not, and studies have shown that though it may seem longer, each dream is can be only about 3-5 seconds long. In the case of a nightmare, it may be caused by anxiety, stress, or something you are worrying about.
Nightmares occur in REM, they differ from night terrors in the sense that they do not cause screaming and unlike night terrors they are remembered quiet well, things like trauma, medication, problems that have been bottled up or stress can trigger nightmares, if you wake up during a nightmare, try to neutralise the nightmare by thinking of positive emotions and pleasant scenes
oh, that makes sense:O