The simple answers include, "from my life" or "I get them by thinking of them," or, in the case of that brilliant pioneer Harlan Ellison, "Schenectady" (he later elaborated that he's part of an "idea club" where he gets a fresh idea sent to him every week).
The more complex answers range from "my life" to "other people's lives" to "daydreams" or "nightmares" or all manner of other responses.
I'll tell you my answer as far as I can see it. Where do I get my ideas?
I don't know.
Obviously, I get them from my mind, but that seems like a dodge. When I say I don't know, that's not entirely true: there are processes writers engage in to help them unlock or cultivate ideas, and of course the lives we lead and the intersections of other lives lived all around us generate ideas, but those answers seem unsatisfying as well. If the question is asked sincerely--as opposed to it being a rhetorical question whose true meaning is "You sure seem to be able to think of ideas that most people can't,"--I think it deserves as best an answer as I can provide.
For me (and I will not presume to speak for anyone else) ideas can come from a few places. Character ideas usually come when I ask myself, "whose story is this--what does this person want and why haven't they got it?" Plot ideas come sometimes from "what if this happened?" (and in science-fiction, the "THIS" can be quite outlandish). I don't often do pure setting/milieu stories, but I suppose they would be "what if the world were like this?"
So. If you're a newly-hatched writer and you're trying to think of THE BIG IDEA, I'd suggest asking those questions. "Whose story is this?" "What does she want, and why doesn't she have it?" "What if this happened?"
It's a sea-captain's story. He wants to be whole again. He's been hurt physically and psychically: what if in his search for wholeness he devolved into unreasoning vengeance?
It's a young son's story. He wants his family back--his father not to be dead, his mother not to have married his uncle, and his girlfriend to not betray him. He'll never have those things, because once lost, they can't be regained. What if he exits this world but takes the guilty with him?
It's a knight's story. He wants the world to be as romantic as the books he's read. What if he convinced himself that the world was like a storybook? What trouble would he cause for himself and his companion(s) if he refused to accept the world as it was and instead lived the life of a romantic, chivalrous knight despite being terrible at it?
I'm sure you recognize those stories. I'm by no means saying it's easy--there is a lot more to Moby-Dick, Hamlet, and Don Quixote than man-vs-fish, man-vs-family, and man-vs-reality there. But at least it's a start!
Be seeing you!