In an original story, you have carte blanche to make up anything you wish. If your story requires that a character defy laws of Earth physics, you can set it in a world you create, where the laws of physics are different. If you need your character to be in a certain place at a certain time, you have limitless possibilities to make it happen. If you want your character to possess a particular trait, you have their whole life at your disposal, to change and alter and twist as you see fit until your reader has no choice but to believe that yes, of course your character needs to be like this; there's no other way for him/her to be. An original story's boundaries, in short, end where the writer's imagination does.
That's not quite the case with fan fiction. A story's boundaries still end where the writer's imagination does, but there are areas where the writer doesn't have carte blanche unless they are writing an "AU" where nothing is recognisable except for character names. I personally do not consider such AU stories fan fiction, because character names are not important. Harry Potter doesn't need to be named Harry Potter, strictly speaking -- even if in canon, he were named Stephen King, and his parents had been Alexander and Ernestina, it would not change the canon story. If I am merely borrowing names from someone else's book and writing a story using those names only, I am not writing fan fiction. I am writing an original story with character names borrowed from another author.
A story where a shy, bashful boy named "Harry" attends ballet school in New York with a rebellious, gutsy boy named "Draco" and there is never even an inkling of magic or a hint of rivalry? Is not fan fiction. It doesn't make it bad. I'm sure there can be a lovely and touching and evocative story written about such two characters in such a setting, but it is not fan fiction. That people write such stories and post them as fan fiction doesn't make them fan fiction: "I like the character names and therefore it's fanfic" is not a valid argument because as I said above, names are irrelevant to story. You can use names to a story's advantage by picking out special names based on meanings to go with different characters, but without the character, the name is only a label even if it was picked out with great care. A rose by any other name, etc.
An argument can be made that it's still fan fiction because the person intends for "Harry" and "Draco" to reflect their canon counterparts, but quite frankly, if what you're writing doesn't actually reflect what you're intending to write, then you're not doing a very good job of writing. And if there are people who sincerely believe that in the Harry Potter books, Harry is at his core a shy and bashful creature, and Draco a gutsy and rebellious one, I would strongly urge them to take another blue pill and call me tomorrow. This isn't the same as having a kink for shy!Harry and writing him that way because you really enjoy it; if most of the rest of the story has recognisable canon elements, it's still fanfic. OOC fanfic is still fanfic, in other words, if it contains other elements recognisable from canon. The only type of story I contend is "not fanfic" is the sort that borrows nothing but names.
There is leeway in interpretation, and it's not mandatory to take canon literally at all times. For example, I contend that sometimes, what we see in canon of "negative" characters is particularly negative because we see those people through Harry's eyes, and Harry's hardly the most reliable of narrators -- he has keen insight and strong instincts but he is not infallible in his assessments, and he is a flawed human being, too, with his own hang-ups. I don't think this unreliability of Harry's narration was ever as clear as when he called Remus Lupin a coward. And believed it! I'm sure there are people out there who agree that what Lupin was doing was cowardly. I don't, but that's not the point. The point is, an objective narrator makes this sort of disagreement impossible. If an objective narrator says someone is a coward, then he is a coward whether the reader likes it or not. It's heavy-handed but it works for some authors (and readers).
At any rate, there is a limit to how far you can stretch what's in the books until it's completely unrecognisable. That, I think, is the crucial element of fan fiction writing: knowing when the stretch stops. Knowing that if you break through, you will no longer be operating under the constraints of the source material. If a single story element "breaks through" like this but everything else is still recogisable, even if very distantly, it's still fan fiction. But when every aspect of a story can't be inferred from canon without some serious mental aerobics, it really isn't, and I don't think there is any point in calling it fanfic, other than the obvious desire to post it to the internet so people can read it and squee at you, or something. Which, you know, to each their own.
An AU where characterisation remains intact even if there is no "Hogwarts history" is still fan fiction, as is an AU where characters are different as a function of an altered reality. Because these stories contain recognisable -- and irreplaceable elements that ground them in the original canon. That grounding is not easy to do. It's even harder to write within canon, keeping both world and character traits intact, because you have to extend your imagination beyond what you think and try to write your way out of another writer's head. This is not to say that fan fiction is harder than original fiction, necessarily; depends on the writer -- some people find it easy to stick to a set of established rules and characterisation guidelines, whether because they share the canon author's worldview or for some other reason. Other people find it hard.
(Aside: I struggle to stick to canon. The reason I enjoy writing fan fiction so much is that it is teaching me how to stick to rules instead of just running roughshod all over the place and introducing inconsistency after inconsistency into my work because I keep changing the world I built to fit my plot. For me, the challenge of writing fanfic is in making it as canon-compliant as I possibly can, but it's actually contrary to how I write, which is really haphazardly and in long, frenzied bursts. This is why I write plotty fic after plotty fic, each trying really really hard to be canon compliant (not always succeeding, but ;_;), and then randomly explode with completely ridiculous crack, because my brain can only take so much discipline at once.)
Sometimes I read stories that appear to be fanfic on the surface, because they use all the right canon buzzwords, but actually are original stories with a veneer of canon superimposed. If I can easily substitute parts of a story with non-canon counterparts (Hogwarts/Beverly Hills High, Death Eaters/Nazis or white supremacists; Cruciatus Curse/torture chamber; Diagon Alley/Fifth Avenue), and if I don't manage to recognise the canon characters, I wouldn't call it "not fanfic", but I would call it "not fanfic enough". Note the I. Note the would. If it can be slightly altered and sold as original, it's not fanfic enough for me. Note the for me. I don't think I am an authority of any sort; this is just how I approach fan fiction as a writer and a reader. That something isn't "fanfic enough" for me does not make it bad. There is no element of "better" or "worse" about it, and fanfic writing is not a contest of who can cram more canon details into their fic to make it super-compliant.
I first began reading fan fiction because my reaction to canon was, and still is: "wow, I really, really like this! :DDDDDDD I like it SO MUCH!! I want more!" That "more" can be a short PWP where Draco does something so painfully IC that I squeal, or an AU where Draco isn't even a wizard but damned if he and Zacharias Smith aren't contrasted in a perfectly canon way, or a long, plotty sequel to canon, or anything that makes me feel like I'm back in that canon world if only for a moment. If a story doesn't give me that, then it's not a story I'm interested in. For me, the more important part of "fan fiction" is the "fan", because I can get fiction anywhere, and even for free, too (library). Only fandom gives me the "fan" part, which is why that's what I focus on when I read in fandom. This is not an exhortation for anyone to feel the same, or to agree -- but this is how I roll, and this is what colours how I look at fanfic.
...and now excuse me while I go back to writing the story where wizarding England nearly gets nuked by the Americans. :P