We're always surprised when we have dreams about people we've thought about that day. Maybe because the thought only lasted for a moment. Yet, just because our conscious thought forgets, the brain synapses that connected are still fresh, even later than night. But why do those synapses make it into our dreams?
Because the hunter-gatherer role of your brain is for thin-slicing a situation. Quickly understanding the elements around you in order to make instant decisions. Your brain tries to create a full story based on the information it is.
Even when we're sleeping and have no new information coming in. That's why you end up in your old house or high school, because it may be the only place that makes sense with the cast of characters dancing in your head.
It's the same way your brain works throughout your waking life. It's why we all think we're so smart. Because our brains have made "sense" out of the infinitesimally small amount of information we have, and made a story out of it. Based on the foolish bit of information we have.
Help your brain out. Visit your local library.