I take other ideas and facts, take them apart, and put them back together into new ones. To take an idea apart, think about what the idea, or parts of the idea, intend to achieve, in terms of emotional impact, in terms of how they change the world into a different shape. A good idea is one that is simple, but changes the world around it in a complex fashion. Read vociferously and widely. Remember facts and ideas, and how they made you feel.
Once you have a mental library of idea fragments, try to recombine them. Especially try combining ideas that evoke very different, seemingly incompatible feelings. The modern conception of vampires is a great example of this: take an undead monster associated with pestilence, combine it with an aristocratic sex symbol, and you have an exciting mix of fear, disgust, admiration and attraction. Vampires are like salted caramel.
Here's how to make new ideas out of existing ones:
Take an idea where there's very much or very little of something and consider the opposite. Find axes along which to vary ideas. If an idea says "one", try "exactly two" or "a million".
If you read a story where humans are much more adaptable than aliens, consider a story where humans are much less adaptable. If you read about an animal that lays 100000 eggs each year, think about an animal that only ever lays one egg. If you read a superhero story where the hero is without fear, think about a superhero whose defining character trait is his abject terror. If you read a story where people live to a thousand years, think about a story where people only live to the age of ten.
Find patterns, formulas in stories and change out the particulars to give different effects.
If you read a story where people live to a thousand years, consider a world where pets live to a thousand years. Or where trees grow in a day. The formula you can extract from the original story is to take some kind of thing and change how long it takes. Now apply this formula to everything, no matter how ridiculous. What if tea took a hundred years to make?
Then think about the consequences of this idea. How does it affect the world? What has to change to make things work? How do people feel about it?
What if tea took a hundred years to make? What would that do to society? Would anyone drink tea? Would it be considered a holy sacrament? A status symbol for the super-rich? Would families have giant cupboards of brewing tea, passed through the generations? Interesting. Now change "tea" to "children" or "swords" or "books."
Here's some concrete examples of ideas in the worldbuilding category on this site, and how I arrived at them.
Alphorns and Airships came from taking Stand Still Stay Silent, which kills off everything below a certain latitude to create a post-apocalyptic world where nordic culture and folklore is important. I took the boundary along which we kill everyone and switched it from latitude to elevation, killing off everyone below the alps to create a world where alpine culture and folklore is important, and the major population centres are now in the Andes and the Tibetan plateau.
Sherlock Holmes as a police fig leaf came from reading a bunch of Holmes pastiches, combined with reading a bunch of things on how police dogs are a way for police to be able to act on their prejudices or hard-to-explain knowledge. The dog notices its handler is focusing on a particular person, and indicates this person to the handler. The handler gets to search that person, and if asked why he searched that particular one, he can honestly reply that it was the dog who pointed them out.
Alien idea: Co-domestication complexes, as I describe in the post, came from thinking about ways in which humans might differ from aliens. I took took the well-used formula "humans are the most X species in the galaxy", then went over remembered facts about humanity and our abilities and development as a sentient species. Eventually I remembered the theory that domestication is not all one-way, that dogs also domesticated humans a little bit, made them a little more dog-like while we made them quite a lot more human-like. That gave me an axis to play around with. How much co-domestication does a sentient species undergo? What if the galactic norm is way more co-domestication than humanity experienced?
Note that there's no magic moment of inspiration with these examples. It's the techniques I described above. Taking existing stories like Stand Still Stay Silent, Sherlock Holmes, David Brin's Uplift. Taking real-world facts and theories like police dogs and co-domestication. Looking for extremes to invert or axes to vary along - Sherlock Holmes as a clever, honest person, or humans as the obvious "masters" of our domestic animals. And looking for patterns where the particulars can be swapped out: anyone past arbitrary geographical boundary X is dead, humans are the most X species.
And that's how I get my ideas.