In an interview in The Twilight Saga: the Official Illustrated Guide, Stephanie Meyer agrees that the question is impossible to answer because ideas come from “a million places”.
John Green says, “Well, my books don’t have capital-i Ideas, really. I don’t have ideas that hit like a ton of bricks out of nowhere, … I would love to have a high-concept book idea fall out of the sky and hit me one day, but it hasn’t happened yet.”
J K Rowling says: “I’ve no idea where ideas come from and I hope I never find out, it would spoil the excitement.”
Veronica Roth says: “I always want to know where my favourite authors get their ideas. … The thing is, for a lot of writers, it’s more complicated than that … it’s actually difficult to answer. That’s why I give a different answer in every single interview I ever do.”
Neil Gaiman says: “In the beginning, I used to tell people the not very funny answers, the flip ones: ‘From the Idea-of-the-Month Club,’ I’d say, or ‘From a little ideas shop in Bognor Regis,’ ‘From a dusty old book full of ideas in my basement,’ or even ‘From Pete Atkins.’ (The last is slightly esoteric, and may need a little explanation. Pete Atkins is a screenwriter and novelist friend of mine, and we decided a while ago that when asked, I would say that I got them from him, and he’d say he got them from me. It seemed to make sense at the time.)”
Ursula le Guin says: “The reason why it is unanswerable is, I think, that it involves at least two false notions, myths, about how fiction is written.
First myth: There is a secret to being a writer. If you can just learn the secret, you will instantly be a writer; and the secret might be where the ideas come from.
Second myth: Stories start from ideas; the origin of a story is an idea.”
This comes from her book, Dancing at the Edge of the World: Thoughts on Words, Women, Places, and is discussed on the Brain Pickings website:
Leonard Cohen says: “If I knew where the good songs came from, I’d go there more often. It’s a mysterious condition.”
But look around. You’ll find plenty of other musings on this question.