By a very circuitous route. When I did my first novel, I had no clue what genre it was actually in. I thought it was mystery, but when I read information about mysteries, the book didn't fit. I remember reading how-to books on mysteries and thinking, "But this doesn't describe my book." Yet I could find similar books in the bookstore. But they were all in mystery. Eventually, I discovered that there were two other genres buried in mystery: Suspense and Thriller. Similar, but with different aspects.
I preferred the action and adventure of thriller, especially things like treasure hunts. But after Books 2 and 3, the genre changed. It became more gritty and violent. Seemed like every book had a body part being cut off or a eye gouged out. That's not me or how I write. So I wrote down all the genres I like to read (four) and wrote down the pros and cons for writing each one. The result was that I took the action adventure/treasure hunt aspect to contemporary/urban fantasy.