Most authors write in only one genre, though some may write the same genre for two different age groups, such as adults and teens (otherwise known as young adults).
It is best to write in the genre you know best and are most familiar with. In other words, in the genre you READ the most. When you read, you become familiar with the way an author writes that genre of story. You become familiar with how they create their characters and what style they write in, how they structure their story. You become familiar with the way their story flows, how they write the conflicts and the resolutions of the story. You really get to know how that particular genre is written because of the books you read.
What if you like to read more than one type of genre? Say you like two particular genres better than the rest, though you may occasionally read from other genres. So maybe you read a lot of books in these two different genres. You could try writing both genres and see which one works best for you.
When you are starting out, you should really focus on writing one particular genre and really getting good at it before you attempt to write another genre. Once you have established yourself in a particular genre, you may want to see if you can then write something good enough to publish in the other genre. There are published authors who have successfully written in more than one type of genre, but for the most part, an author typically sticks with one genre.