What Josy said basically, often I can trace the reason I've had a dream back to something that happened the previous day, like something you saw or a conversation you had and it fell into your subconscious and was used to form a dream, it's just strange how when those moments happen during the day you'd never think you'd end up dreaming about them.
An example would be I once had a dream about going on a random car journey in the middle of the night with my cousin I think it was, and in the dream I had a vivid image in my head of the speedometer, and then once I woke up I remembered the previous day I'd been in the car with my dad and had glanced at it and it obviously stayed with me, and I think I'd thought about texting my cousin to arrange something, so obviously the dream formed out of that. Strange though