There's only one rule for how to write a story, and that's: "Write a good story." Apart from that, anything goes, as long as you can pull it off. (And some things are harder to pull off than others.) But sometimes, people will try and teach you ironclad rules of fiction writing. Like, avoid an omniscient narrator, or introduce your main character on the first page.
There's only a few things it could mean when someone tries to teach you the rules of writing.
Every writer has rules that work for him or her personally — that's part of figuring out how to make this crazy anarchic process happen. At the very least, you can't write any story without figuring out what rules you're going to follow for that story in particular. So it's easy enough to go from figuring out rules that work for you personally to deciding that you've got the rules that work for everybody — and indeed, these rules might turn out to be helpful for you as well.
And if someone says, "This is the rule everybody should follow," just try and hear, "This is a rule that works for me personally, and might work for you." And really, this person is giving you an insight into his or her writing process, which could be super valuable and help you to cop a bit of that writer's mojo. A rule that works for someone else is often something you should at least give a try.
And if you want to write epic fantasy or hard space opera or whatnot, then you will indeed have to know what rules people currently writing in those subgenres are adhering to. (Unless you want to be the radical rebel who redefines the genre, or dies trying. Or, in some notable cases, both.)
3) This person knows that some writers can break these rules and prosper — but has decided that you're not one of those writers.
At least, not yet. Because maybe you need to learn to color inside the lines before you start ignoring the lines. Maybe you need to figure out how to write a pretty standard issue story, where we meet the main character in the first sentence and the conflict is spelled out right away and the action is fully linear and there are no adverbs and everybody learns a lesson — and then once you've mastered that, you can start mixing it up.
On the other hand, let's say for the sake of argument that you're an absolute beginner like David Bowie. And you're still writing your first few stories ever — following someone else's rules, no matter how simple, might make that early learning curve *harder*, not easier. You might be trying so hard to conform to this other person's formula that you get messed up. Plus, when you're just getting started, that's the time you should take the most crazy risks. Try everything. Try everything twice. Don't look both ways before you cross the street. Make as many and as crazy mistakes as you can. Your early stories are probably going to be epic disasters anyway — although you might break that rule, too — so you might as well make the most interesting mistakes possible. You'll screw up either way, and you might learn more by screwing up big.
Should you have a code of honor, like a noble warrior in the wasteland? Or should you just write without any rules at all? This is obviously a super personal decision, and one that probably results from making lots and lots of mistakes along the way.
(Plus if you listen to enough publishing people talk at conventions or whatnot, you'll hear stuff like, "I hate when a fantasy novel is written entirely in the second person, future tense. That's an auto-reject." And you'll learn a few things that might make your book or story a harder sell. These things aren't rules, they're just things to keep in mind if you want to sell your work to a mainstream publisher.)
Just like there are no rules that work for everybody (other than "finish that story"), there are no rules about whether you should personally have rules. But it's probably true, for most of us, that every story has its own rules.
Like, if you start writing a story in tight third person, you probably can't slip out of third person into first person halfway through the story without annoying the reader. You might decide that a story is going to alternate between events in the present and flashbacks, and that means you're more or less committed to that structure for the rest of the story. If you set a particular tone in this story, you'll want to stick to it. Don't write any checks you're not going to cash, don't cash any checks you didn't write. Etc.
(But of course, you can always revise the story from the ground up, and then the "rules" for that story can change.)
So let's say that for all but the most experimental fiction, an individual story or novel is going to have its own set of rules — in which case the question becomes, "How much do you want the rules for this one story to become the rules for every story you write?"
And the answer to that question, in turn, depends on a lot of stuff — including the trade-off between consistency and freedom. You may want the leeway to sit down and figure out the "rules" anew every time you start to write a piece of fiction. Or you may want to stick to a set of choices that you know work for you. Plus, you may decide that your "brand" as an author includes a set of parameters, like "tight third person narration" or "experimental tone-poem time-slips," and you want readers to feel confident that they'll always get those things when they see your name on something. Not to be crass, but part of getting a following as an author is creating a consistent brand — but of course, your brand can be "you never know what to expect with this writer."
I guess my final thought here is: You don't have to have any rules at all, at least not rules that apply to everything you write. But if you do have consistent rules, you should at least know what they are, so you're not applying them blindly — or serving them rather than having them serve you. Rules should work for you, or there's no point to them.
Oh, and one other thing that's a more or less universal rule — try to have fun, as much as possible. You're making shit up. That should be fun, at least some of the time.