What she is, above all, is more: more beautiful, more intelligent, more capable, more unique; the youngest ever to accomplish something, the last of her race, tribe, or family, the first to gain magical powers or the last to retain them.
Mary Sue shows up regularly in fan fiction and beginning writers' novels. She even shows up in published novels.
For example, Ayla in the "Clan of the Cave Bear" series of prehistoric fiction would be a Mary Sue by pretty much every definition I've ever seen. Not only is Ayla beautiful, intelligent, athletic, and a very quick learner, she also single-handedly tames a horse, a wolf, and a lion, has a lion as her totem animal as symbolized by a set of scars that in no way detract from her beauty, wins over all of the most desirable males everywhere she goes, invents a few key prehistoric tools, and makes a few scientific discoveries on the side.
Another Mary Sue example, a male this time, is Wesley Crusher from Star Trek. Youngest, smartest, always where the action is, often saving the day in the nick of time, permitted all sorts of behaviour nobody else can get away with, and so on.
Mary Sue is fun to daydream with and to write, but not a lot of fun to read. Frankly, she gets annoying very quickly. Other people's hero fantasies rarely mesh with your own.
The main way to avoid writing a Mary Sue character is to know how to identify them. Without practice at creating and identifying realistic characters, this can be tricky, so there are a number of online quizzes aimed at telling you if your character is Mary Sue or not. Two of the more well-known ones are the Universal Mary-Sue Litmus Test and the Original Fiction Mary Sue Litmus Test. There are variations on the tests that are specific for fan fiction, original fiction (linked above), role playing characters, and so on.
There are two main things to remember when doing those quizzes, however. First of all, they are not conclusive. Mary Sue is not a beautiful, competent, unique character, Mary Sue is an unrealistically beautiful, unrealistically competent, unrealistically unique character. Characters can have many Mary Sue characteristics, but if they are drawn realistically instead of idealistically, then they are not Mary Sue. Second, creating a character that has all traits exactly opposite the ones in the Mary Sue list is no better - she's the anti-Mary Sue and is just as unrealistic.
Easier said than done, all you have to do is create realistic characters! Yes, that's all...
The quizzes linked above can help with that, however. You don't have to avoid all beauty, competence, and uniqueness, but try to avoid having too many such traits without some good flaws to even out the character. Good flaws, however, are probably a topic for another day.