So, let's talk story structure. In this theory, the Mary Sue isn't the cause of a story's problem, but the symptom. In a "proper" Mary Sue story, you have a number of structural similarities:
The story is structured as a power fantasy.
The story arcs lack a meaningful middle.
The story is written to entertain the writer.
The story revolves around the lead character despite the narrative.
The lead character is a personification of the writer.
Much of the arguing about a Mary Sue traces its roots to the basic structure above. Eliminate any of them, and you get something Mary Sue-ish with out actually being a Mary Sue.
The points follow.
The Story Is Structured as a Power Fantasy. By itself, there's nothing wrong with a power fantasy. The entire male-oriented fantasy genre is predicated on this very notion. Power fantasies are part of growing, and part of living in a world where you aren't powerful. By itself, this does not make the Mary Sue bad. Change the story structure, and you can wind up with a Mary Sue that works as a character despite having Mary Sue traits. For example, in comedies, there is often an episode where a perfect person shows up, prodding the lead characters into jelousy. As the comedy is also written to entertain the reader, this usually winds up successful.
The Story Arcs Lacks a Meaningful Middle. This, by itself, damns the Mary Sue story. This is what people mean when a Mary Sue comes along, instantly solving all the problems. Proper plot arcs have a beginning, middle, and end. If you take out the middle, the arc feels empty. The middle part is the meat of the story. The beginning acts to introduce the story, while the end exists to wrap up the story. None of the story means anything if the middle isn't there.
The Story Is Written to Entertain the Writer. This part is actually bad writing. This is a damning aspect of the Mary Sue story. The tales themselves just aren't interesting because the writer does not bring the reader along with them. The writer leaves the reader behind, which is among the surest ways to get a story labeled as bad writing. Entertaining a reader, someone else who doesn't know you or care about, is a distinctly different skill, requiring an entirely different approach to storytelling.
The Story Revolves Around the Lead Character Despite the Narrative. That may sound odd, as the story usually revolves around the main character, yet this is the case. While not as apparent in original fiction, in fan fiction, where an existing set of characters have an existing set of relationships and existing levels of importance, altering the central character can change the balance of power. Even in existing fiction, the character has a central role connected to nothing. In its way, this central role is the epitome of privileged. Everything revolves around the lead character because that's the lead character's privilege. The universe really is built around the lead. Compare this to the basic story structure of man vs. environment, where the worlds is at odds with your lead character, and you can see that an important element of the story simply doesn't exist.
The Lead Character Is a Personification of the Writer. This bit has been written about extensively. Yet, this element isn't necessarily bad. How many peudo-memoirs contain personifications of the authors? Pretty much all of them. The mere personification of the author doesn't make a story bad. What makes the personification bad is that the reader can't connect with the character at all.
Am I right in these observations? Do I get to stand up and say, "HA!" and wave my flag of rightousness. That I could be so brilliant. But I do think that I'm on the right track. By focusing on the story rather than on the particular behaviors of any character, we no longer need subcategories or variations. Ideally, this idea takes us from sympton based analysis to evidence based analysis.
Now that we have a structure, we have a question: why this structure? What unites all these people writing all these stories?
I contend that the basis of the Mary Sue story is play behavior. If you aren't familiar with children, you won't realize just how competative play behavior is. This stuff is pure playground level PVP, especially among girls. If you hear how kids play let's pretend, you will see most of these structural elements in play. "Sabrina gets a new magic power, solves you problem, and now you can come to my dance party."
As kids get older, such play slowly goes extinct, but not for everyone at the same rate. In order to tell an adult style story, new skills must be developed as the old skills fade. But, juding by how self-centered many adults are, I'm not sure that anybody grows out of that competative storytelling at all.