Have you ever started a story with one idea in mind, then suddenly realized your story was heading in a completely different direction? I go through this on a fairly regular basis, but that could be because I'm a pantser (someone who writes by the seat of her pants). Of course, I've heard from plotters (people who outline and plot before ever writing a word in the story) who get surprised by their characters.
Just a little while ago, my sister told me she'd started a story she thought was going to be a fantasy, but it was turning into a romance. She's never written a romance that I know of and I'm pretty sure she doesn't read them. I've talked enough about the romance genre (since I edit for a romance publisher) that I'm sure she's picked up a few basics. She didn't seem too thrilled about inadvertently starting a romance story, but here's the advice I gave her: just write the story and let it go wherever it wants to go.
She's a panster like me, so it's fairly easy advice to follow if she's willing to just let the words flow and not try to control the characters too much. One thing I've learned through my 13 years of writing fiction is that the characters can easily take control of the story. Once they do that, you just sit back and watch the story come to life as you type. If you try to get the character to do something he doesn't want to do, the story stalls out.
When you write like I do, and like several writers I know, you have to be flexible. If you have a set idea in mind for what your story is going to be and you're not willing to change that when the characters seem to have other ideas, you're going to spend a lot of time frustrated. I know, I've been there and done that. Once I let go and just wrote what I didn't want to, the words flowed freely and I fell in love with the new tack my story took.
So is it important to have some idea of where your story is going? Sure, because it'll give you a goal to work toward. But you also need to be willing to adapt your ideas as necessary or you're likely to end up with mechanical writing. Just because you want your story to go in a certain direction doesn't mean your characters (once you get to know them a little better) will want to go in the same direction.
Be flexible. Work with your characters' personalities and reactions to situations instead of against them. Your writing life will be easier and your readers will enjoy the story more if you don't try to force your characters into a story where they don't quite fit.