It's hard to build a recognizable identity while genre-hopping. The more successful you are with any one style or genre, the more both readers and publishers are going to demand more of the same. Based on my observations of writers in the wild, however, there are several potentially successful strategies for mitigating this.
Be insanely prolific: Stephen King is known for horror. Isaac Asimov was known for classic SF. But both have written widely across any number of genres. Both wrote enough, and successfully enough in their home genre to get carte blanche from both fans and publishers to at least try other things.
Be insanely successful: JK Rowling could probably write a telephone book and get it published. She's such a successful writer that people are at least willing to roll the dice on anything she wants to write (which is apparently unexceptional mysteries).
Have a unique voice, approach, or characteristic themes. Samuel Delany has written across a wide variety of genres (SF, Fantasy, Non-Fiction, Erotica) but he has such a distinctive voice and perspective that people seek him out for that, rather than the specifics of a particular book. Neal Stephenson is similar --his books are all very different, but they are nearly all intellectually and philosophically adventurous meditations on the intersection between human beings and technology. Several other answers have mentioned Terry Pratchett's Discworld series --I'd also put him in this category. The subgenres may vary but a Pratchett/Discworld book is a reliable brand as a whole.
So to summarize, either you play the "one for you, one for me" strategy of giving people enough of what they want from you to buy indulgence for your passion projects, or you make genre-hopping your brand, by producing books in each genre that couldn't have been written by anyone other than you.