Canon is essentially the fluff of a setting that is officially approved by whomever is in charge of that intellectual property.
When a fiction story is told, the story makers have to create events which did not happen, make up people who were never born, travel to places that don't exist, and create things which never were. That collection of things that aren't real, and only exist within the world of make-believe of the fictitious story being told, is the canon of that story. This notion of canon is important to storytelling, because it allows storytellers to separate the scope of their made-up world from the scopes of other made-up worlds. If someone were to ask "Why aren't Star Destroyers fighting The Enterprise?" the answer is "because Star Wars and Star Trek are in separate canons."
When another storyteller creates a story, and they re-use elements from a different story's canon, it can be said that the new story is "within the old story's canon". This phenomenon - re-using story elements - is often known as fan-fiction. A good example of this are the Sherlock Holmes books: when Sir Arthur Conan Doyle was done writing his books and short stories about Mr. Holmes' adventures, he said that anyone who wanted could write stories about Sherlock Holmes, Moriarty, and anything within the "canon" of his stories. This has spurred many fans of Sherlock Holmes to write stories about him. Due to how Sir Doyle worded his release of canon ownership, it may be construed that any story written about Sherlock Holmes is "canon" instead of "fan-fiction"; read below for more on this idea.
When a story is told by multiple people (or a person chooses to set their new story within the canon of an old story), it is often the case that some things are described as being "real" within that story world which are generally accepted to be "not actually real" (either by a majority of the fans or the current "official storyteller"). These stories or story elements can be stricken from the canon for a number of reasons, including but not limited to: "these stories are bad", "elements in these stories contradict older parts of the canon", "elements of these stories devalue elements in older stories", and "the original storyteller/s didn't say it". In essence, the notion exists that some made-up stories are more "real" than others, even if they take place in the same universe. Quite often these non-canon stories come in the form of amateur fan-fiction. For example: J. K. Rowling is not beholden to include, mention, or reference anything which occurs or exists in My Immortal within any future Harry Potter works. Thus, My immortal can be said to be non-canon. Why is this the case? Because Rowling came up with the story in the first place, she is the storyteller, and she has the power to say what is or isn't canon (more on this later).
Canon itself can be sometimes unclear or subject to change, especially in works which have more than one author and have been poorly managed. "Being subject to change" can be often seen in changes that occur between editions of a roleplaying game; for example, in 3rd edition D&D, the transformation of a Drow into the monstrous Drider was a punishment; in 4th edition it is a blessing the goddess bestows on the best of the society. When elements of the canon are changed in a way that counteracts parts of the previously established canon, it is called a retcon. Retcons often induce rage.
Given that canon, the supposedly-always-extant elements of a story, is somehow fungible, mutable, and iterative, people who like stories often get into fights about what is canon and what isn't (especially if these stories have been told by several people across several decades or centuries). These are debates of canonicity.
A lot of people confuse the idea of canonicity with 'continuity', 'consistency' or 'consensus'. Many fans of many stories will tell you (or anyone who will listen, and many people who won't) they have a "personal canon", or "headcanon" for a story or fictional universe. Sadly, that's not how canonicity works. The official, capitol-C "Canon" is what someone who is in charge of a particular fictional world tells you counts or doesn't count (more on this soon, I promise). Conflict arises when the canonical judgement on what exists doesn't match the consensus view of what should exist. For example: Jar-Jar-Binks is part of the Star Wars canon, because Disney says so; however the general consensus among Star Wars fans is to pretend that Jar-Jar-Binks never existed. This is known as fanon because this consensus view is most often adopted by the average fans of a franchise, even if it directly contradicts the canon proper.
Managing the canon of an old story, passed down to different storytellers (or teams of storytellers) over the years, can be a big hassle for the current storytellers who have been granted the power to run the show. There are numerous ways to go about this, but the two most common solutions are to either discredit huge portions of the canon (these are often known as reboots' or re-imaginings, and cause huge fits of bitching about the current storytellers online) or ignore the problem entirely and march on telling new stories by whims and broad strokes (causing huge fits of bitching by fans at other fans online about "what's canon"). These are generally accepted to be poor ways to go about managing the canon bureaucracy.
Doctor Who is an example of a work involving multiple authors where the shows producers have officially denounced the notion of canon, by stating: "It is impossible for a show about a dimension-hopping time traveler to have a canon." The show (and spin-offs) has continuity and consistency (such as how he's always played by a British man, though not the same actor, even though the Doctor can shape-shift into a person of any nationality or gender), but no official canon. There was even that one season where The Doctor was female.
Canon is also different from consistency, which is the look and feel of a series as a whole, rather than exact details. When fans talk about "being faithful" to a series, they are talking about maintaining consistency.
It should be lastly noted that canon ≠ cannon, no matter how frequently it is used as such.
Who is the Storyteller?
When all stories were told around campfires, the storyteller was whomever was telling the story. Unless someone was re-telling a story (and was within earshot of the creator or a hardcore fan of said story), the person speaking had full control of the story. Because a storyteller immediately saw their audience's reactions to their story, they made sure to make the best story possible, because otherwise their listeners would lose interest. Canon was only relevant so long as someone could recall what happened in a story from ages ago, since nobody write things down. Issues of canon only arose when someone shouted out in the middle of a story "Hey, that's not what you said last week!".
In the modern age, stories are written down, published for a wide audience, and poured over in great detail. A story can also be owned as Intellectual Property. This means that someone can buy the legal rights to a story, or assume control over the people that do, effectively making them the new storyteller. This is a very common issue in things like comic books and movies, and less so in things like literature and fables. Anyone who legally owns the rights to a story can sue someone for writing another story that includes elements of their original story. This can also mean that some pretty shitty elements can be injected into the canon of a beloved story, and nobody can do anything about it.
Stories which are within the public domain are legally the property of everybody. This doesn't strictly mean that all fan-fiction is canon, but it does mean that there is no legal storyteller. If the author is still alive and telling new stories in their universe, this is generally the most-agreed-upon source of new "official canon". If not, the fans may find themselves surrounded in fan-fiction of varying levels of quality, some of it "deserving to be canonized" and most of it "bad garbage". This is what happened to Star Wars before Disney acquired it. Though it wasn't in the public domain, George Lucas said that people were free to make and sell new stories. By the time Disney killed this huge cloud of fan works, they had amassed themselves into several "tiers" of canonicity; some people to this day demand that stories like the Thrawn Trilogy be made honorary canon on account of their popularity and high quality.
Roleplaying Games and Canon
When an RPG is made, the creators of the game almost always include a setting: a canon which players and their game masters can use like a sandbox. The game master is generally seen as the arbitrator of a story which both the game master and players tell together (generally aided by dice, rules, and snacks). If the role-playing group is telling a story within the scope of the canon of the RPG, that begs the question of whether or not the story told by the game they play is canon to the world or not.
Pretty much everyone says no, because that would be silly. It would be insane and completely fun-ruining to force players and GMs to abide by the events of other games being played half-way across the world. This would only work against the GM's ability to guide the story, and work against the player's agency in the world that the GM is orchestrating for them. Where roleplaying games are concerned, canon is reset between campaigns, and rarely are characters or events carried over between any two arbitrary games. If someone is demanding that a game or character they played is canon in your new game, they can almost always be assumed to be That Guy.
The one exception to this rule is Vampire: The Masquerade. This game is well known for having a huge density of LARPers within it's player base, and they would gather in huge nation-wide conventions to make their games, characters, and in-game-events canon going forward. It was a huge experiment in role-playing games, and there are still debates today as to whether this experiment was a success or a failure, given it's recent decline in popularity.
Sometimes events in certain games become so legendary among traditional gamers (or just /tg/) that the creators of the game declare it's characters and events to be officially canon.
Games Workshop and Canon
Games Workshop's official stance is that all of the fluff is told by an Unreliable Narrator and comes from a compromised position where all the facts may not be known, or deliberately concealed, so is therefore true and false at the same time. This is so they can sell you multiple stories and products without having to wade through 25 years worth of bullshit, self-contradictions, and inconsistencies. This frustrates and annoys fa/tg/uys, who pull a fit every time their comic book collection gets even slightly out of order. However, it's pretty common practice in most large franchises. This stance actually allows individuals to have their own personal canon and are able to pick and choose canon as they see fit.
This particular stance by GW is detailed by Gav Thorpe, who has been both a games developer and an author:
"[...] is the job of authors and games developers to illuminate and inspire, not to dictate. Perhaps you disagree with the portrayal of a certain faction, or a facet of their society doesn’t make sense in your version of the world. You may not like the answers presented, but in asking the question you can come up with a solution that matches your vision. As long as certain central themes and principles remain, you can pick and choose which parts you like and dislike."
But of course, people don't see it that way and would rather be dictated to, instead wanting their galaxy-sweeping, massively-scaled space opera to be detailed right down to how many pubic hairs Roboute Guilliman has. Warhammer and Warhammer 40,000 have continuity and consistency to an extent, but nothing can be truly described as canon, as the powers that be never set anything in stone (and likely never will).
In the words of Marc Gascoigne (overall manager of Black Library prior to 2008):
"I think the real problem for me, and I speak for no other, is that the topic as a "big question" doesn't matter. It's all as true as everything else, and all just as false/half-remembered/sort-of-true. The answer you are seeking is "Yes and no" or perhaps "Sometimes". And for me, that's the end of it. Now, ask us some specifics, eg can Black Templars spit acid and we can answer that one, and many others. But again note thet answer may well be "sometimes" or "it varies" or "depends". But is it all true? Yes and no. Even though some of it is plainly contradictory? Yes and no. Do we deliberately contradict, retell with differences? Yes we do. Is the newer the stuff the truer it is? Yes and no. In some cases is it true that the older stuff is the truest? Yes and no. Maybe and sometimes. Depends and it varies. It's a decaying universe without GPS and galaxy-wide communication, where precious facts are clung to long after they have been changed out of all recognition. Read A Canticle for Liebowitz by Walter M Miller, about monks toiling to hold onto facts in the aftermath of a nuclear war; that nails it for me. Sorry, too much splurge here. Not meant to sound stroppy. To attempt answer the initial question: What is GW's definition of canon? Perhaps we don't have one. Sometimes and maybe. Or perhaps we do and I'm not telling you."
On the other hand, some authors have truly taken the piss with this policy, such as Captain C.S. MULTI-LAZOR. However, even Games "everything is canon but not everything is true" Workshop have standards, and draw the line at his work, with one of their spokespeople saying it could've benefited from an editor's red pen.
The /tg/ Consensus
When it comes to things like Warhammer 40,000, fa/tg/uys tend to throw canon out the window and deal with the setting on their own terms, establishing their own continuity through group consensus (the aforementioned fanon). Picking and choosing which retcons to accept and which to ignore is one of /tg/'s greatest pastimes, and to this end /tg/ has an established a board-wide consensus for almost any setting with more than one edition or author (i.e. all of them). This consensus tends to cross-pollinate with the stuff non-/tg/ fa/tg/uys also tend to like.
To again use Warhammer 40k as an example, an entire "secret" consensus has arose within the fandom, a continuity that "fixes" poorly received retcons, patches up consistency issues, and tends to lighten the characters and infuse awesome into the setting wherever possible. /tg/ has even developed an entirely separate universe wherein fa/tg/uys can put all of their homebrew characters and factions.
Note that this a consensus, not an official canon. Canon is, in theory, what they say it is, whereas consensus fanon is what the majority choose to accept.