I read the other day, that this is a common question that authors get when doing interviews or question and answer posts and etc. And let me say, that I look forward to the day that someone asks me this question.
I remember Gary Larson answering the question about his comic strips. He wondered if people imagined that he climbed up into his attic and secretly opened a trunk stuffed full of cartoon ideas. That's not how it works. There is no secret, trunk or otherwise.
I have a hundreds of ideas for stories every day. I don't have time to even write them all down. If I did nothing but write down ideas, I would never have time to write anything else, and maybe not even time to write them all.
In fact as I write down one idea, it spawns two or three other ideas. (I would love to find a business where I could sell these ideas. Even at a few pennies apiece, I would quickly become a rich man.)
I will be the first to admin that many of these ideas are bad ideas. And others are ideas that have been written over and over by other authors.
From the ideas that are not already covered by others, and that are not bad ideas, kick around my head for a few days, weeks, months or years. And they collect other ideas. At whatever rate of progress eventually these good ideas organize a gang of other ideas and demand to be written.
At that point I write them down. I work on them. I stay up for hours at night to get the first draft out of my head, and onto pages. Sometimes they continue to build momentum. Most time they rest for a while before getting polished and finished.
There, that is where I get my ideas.
Now, I just had an idea for a new story about a guy with a magic box that I have to go write down, so I have to go now.