Sometimes it's music. I've a fantasy trilogy inspired, somehow, by Amaranth by Nightwish. (Later, Amaranthine by Amaranthe influenced it because the feel & message in the song was already in the story. It scrolled across my YT suggested.)
Sometimes it's a what if. I've a dark anti-hero novel in the works inspired by the "what if there was a story about a true sociopath falling in love and learning to deal with it?".... Don't ask why super heroes genre was what this one wound up in.
Sometimes it's from a show or manga I like. I've finished an epic-length work that started off as what was supposed to be a series of one shots based on the ideas presented in Monster Musume.
Then of course there's the D&D games. I've never made a story based around a D&D game, but I've used characters inspired by characters at my sessions. I'm a bit of a world builder, something I started doing a lot when I became the regular DM for my old group... Usually something will spark an idea, a thought, or I'd lament over something I wanna see in a setting... And then i'd make it. After I flesh the setting out to my satisfaction, I sit back and just start seeing what stories can play out in it.