An average person sleeps for eight hours a day, and two hours of those are spent dreaming, which is a natural part of our sleep cycle.
Dreams are thought to be your brain’s way of helping you process emotions you experienced during the day. You might find yourself feeling very stressed, overwhelmed, anxious, etc., going to sleep, but then feel better after a good night's sleep. (A good idea might even come to you after a good night's rest.) Dreaming can serve as an emotional release. For example, having a dream about flying or floating could possibly be your subconscious encouraging you to let go and breathe about a worry you are holding on to. There is an interesting theory about dreams that dreams help sort information that happened during the day, and your brain decides whether each moment should be kept or forgotten about.
Throughout your time of sleep, your brain cycles through various stages of sleep, each typically around 90 minutes. You start with lighter sleep, go into the deeper stage, and then back to lighter sleep again. Though the REM stage results in the most intense dreaming, dreaming is also still possible during non-REM stages of sleep, but is often less cinematic and more thought-like.
When we dream, we go through vivid mental imagery, emotional shifts, and varying levels of awareness. Neurotransmitters and hormones play a role in shaping our dreams. Dreams are mostly visual, but can also involve all of our other senses.
Nightmares are completely different though, as they can cause moments of sudden distress. Nightmares can contain problems that you have never encountered before, or it can mirror a real life fear or trauma. Nightmares can also be triggered by daytime stress.
So there you go! Now you know how your sleep cycle works, and the reason it is so important (and interesting) to get your sleep.
https://www.calm.com/blog/why-do-we-dream