I'm not really a writer, though I really want to, but here is my opinion on the whole thing: It depends.
If you want to sell your story or something, the best would be do choose a genre. The genre have specific audience. There are certain audience for the Science Fiction Genre, a certain audience for Romance Genre, a different audience for the Super Hero genre, etc. You might have to research this. Or maybe you know a person or persons who reads the same genre you are writing for. Writing for a specific person or persons could help you.
Then there also traditional publishing, that is publishing thought publishing companies like HarperCollins. These companies have their own audience and they tend to publish only certain genres. They have rules and guidelines to what they would receive.
There are also fan fiction which already have an established audience, the fans.
Many though really just write for themselves. Their audience is themselves. You might think that is kinda restrictive but not true. If you have certain taste, then there are thousands, if not millions out there, who share it. If you really like what you wrote, then there are thousands if not millions of others who would like it too. Still, if others don't like it, no problem. The most important audience is you and that is the only person you have to satisfy.
Have an audience in mind, even if it is only a single person, even if you write only for yourself. As long as you have an audience in mind, then there is no problem. Even the very niche, there are still thousands out there as the audience for that. The problem actually happens if you don't have a clear idea of what your audience are. If you have no clear audience in mind, then your story would likely have no audience at all.