It's true that you don't dream as soon as you go to sleep. Usually, it takes about 90 minutes (1.5 hours) before you experience your first dream. Dreams usually occur in a phase of sleeping called REM sleep. REM sleep is named for the Rapid Eye Movements that occur beneath your eyelids while you are in this state (and while you are likely to be dreaming). Once you lie down to sleep, you go through deep (non-REM) sleep stages for about 90 minutes before you enter REM sleep. As the night progresses, you spend more of the time in REM sleep (and dreaming) than non-REM deep sleep and your REM/dream periods get longer. Although it usually takes 90 minutes before the first REM/dream stage happens, if someone is sleep-deprived, REM and dreaming may begin earlier.
Although people sometimes suggest that they "did not dream last night", this doesn't really happen. Everybody dreams every night, but not everybody remembers what they dreamt. One estimate from sleep researcher Allan Hobson suggests people forget 95-99% of their dreams. If you wake up in the middle of a dream, you will likely remember it. If you wake up between dreams, you probably won't. In fact, sleep researchers will often monitor subjects' brain waves and eye movements and wake them after they've been in REM sleep for a little while. These subjects typically report that they were just having a dream. This is true even for people who claim they don't have dreams.
How does the brain form dreams and what do they mean? One old theory comes from the famous psychologist Sigmund Freud. Freud wrote a book in 1900 called The Interpretation of Dreams. He suggested that dreams have a hidden meaning that comes from subconscious (the forbidden thoughts that we are unaware of). For example, someone who practiced dream interpretation might suggest that a dream about a king and queen might really indicate that one is subconsciously thinking about her parents. More modern theories of dreaming are based on the events that occur in the brain. Sleep researcher Allan Hobson suggests that dreams occur because the we are trying to make sense of random brain activity. One area of the brain (in the brainstem) stimulates other areas of the brain (especially in the cerebral cortex) that are normally involved with sensing the world and interacting with it. When we are awake, these areas are active because of input from the outside world. When we are dreaming, they are active even though there is no input from the outside world, only from the brain itself. The brain tries to make sense of these random brain activations by weaving a story around them but since they're fairly random, they often don't make much sense.
Here are links to two good sites to read up on sleep and dreaming:
making a small donation to science.ca.