Whether you're a writer or not we all have ideas every single day. It's just that usually for the writer it's not a passing thought. If an idea catches our interest we follow it, explore it, see it out. Taking an idea from seed to fruition is quite the journey.
And while it is often this journey that writers look forward to the question still remains... where do you get your ideas?
I've heard famous stories of writers saying they had a dream and then suddenly it was a story. Maybe, the magical good idea fairy visited them in their sleep and sprinkled idea dust on them...
For real though, if this is a thing, please feel free to slide into my dreams.
I think the more likely, still magical, explanation is that dreams are our way of consolidating and processing information gathered during the day. Everything we interact with, experience, dwell on, can make its way into our dream state. And while not usually dreaming this is often how I get my ideas.
I overhear a random bit of conversation, I meet someone new and make up an entire backstory of my own creation with no ties to reality, I listen to song lyrics and make up a story to go along with it, I read a story or watch a show and think but WHAT IF?
WHAT IF are words constantly going through my head and they are how a seed of interest becomes a full-blown idea. Something novel will grab me and I'll walk with it for a bit. Tell myself stories about it at night, write snatches of dialogue for characters who don't yet exist, it grows, twists, becomes its own thing. Sometimes it takes minutes or hours, and sometimes I'll walk with an idea for years; adding to a collection of musings I have on it until it all clicks and I know what the story is.
Or at least the story of the first draft :)