For me, the vast majority come from the process of writing - very little happens until I start making the words appear. The ones that come with writing don't always have to do with what I'm writing - and that can be very distracting.
Sometimes an idea will appear as the result of something I'm reading or watching; some tangent from the story or text. More often than not, these don't get very far.
Rare gems appear mysteriously out of nowhere; a scene or thought, with no apparent explanation or source, that won't let go. So I make up a story to explain it. (Terry Pratchett's inspiration particles remain the best explanation that I have for these ones.)
Whatever the source, I am a firm believer that inspiration only works for those that are seeking it. I imagine that everyone has them, but if you are not searching for them, waiting for them, needing them, then they quickly fade away like last night's dreams.