As Freud pointed out, dreams are (among other things) expressions of either 1. forbidden wishes that have been put out of consciousness (repressed) or 2. traumatic experiences that have been similarly repressed. Nightmares are simply dreams containing strong anxiety feelings, strong enough to wake you up. Anything which is repressed strives to become conscious again. When awake, the things we do to keep things out of consciousness (our defenses) succeed in keeping us unaware of the frightening wishes or traumatic experiences. When we are asleep, our defenses are weakened and the repressed material becomes conscious as a frightening dream, that is, a nightmare.