It is during REM that the hippocampus and amygdala, two organs in our heads responsible for memory and emotions respectively, and areas in the frontal and prefrontal lobes near the forehead responsible for attention and coordination, work together in dream production.
If, for example, you have a fear of flying and it’s literally on your mind, you’re more likely to produce an associated image of that fear, which then emerges during REM as those emotionally-charged areas of the brain become activated.
Exceptionally vivid and memorable dreams occur just before we wake up, but it’s possible that we’ve been dreaming similar themes all night long during the four or five phases of REM that we go through. So even though we recall just what we dreamed about in the last cycle, it could be reflective of the night’s cumulative dream content. Like a single television show with one theme interrupted by unrelated commercials, which are the other phases of sleep where we don’t dream.