As a writer, I get this question a lot. I don't mind because it means the person asking is genuinely curious. Then there are moments where the question sparks something interesting.
I generally store plot points, scenes, and ideas in my head (sometimes on the laptop). I don't always know what story or character they fit with and sometimes they don't fit any, but they're in there. I was talking with my chiropractor today (I tweaked my back earlier this week and needed an adjustment) and the the notion of where ideas come from came up. I mentioned that the third Tom Myers Mystery will open with a scene based on a real event that happened not far from where I live. That scene is the catalyst that kicks off the story.
I also mentioned a plot that's been percolating for about five years now based on some news reports I heard about seemingly unrelated murders, but not so out there to see how they could be. I tucked the idea away. Not sure when or where, or if, I would use it.
On the drive home, my brain kept replaying that particular plot until I realized that is wasn't it's own separate plot, but part of a plot for a novel I'm just starting to put together. Once I realized the connection, the story exploded.
And this is why I love my job.
This is the magic of writing.