What's wrong with a Mary Sue?
said, the term came from a story written to parody bad fan fiction, especially the tendency of fan authors to insert thinly veiled surrogates of themselves as heroic guest characters who were better at everything than the main cast and whom Kirk, Spock, and/or McCoy all fell madly in love with and/or needed to be rescued by. It came to be a catchall label for such unbelievable, contrived wish-fulfillment characters, particularly ones who didn't actually display any of the qualities that supposedly made them so brilliant and wonderful and adored, or ones that only outperformed the leads/won their undying love because the leads were written hugely out of character. (For instance, the guest scientist in the Bantam novel Vulcan!
who's better than Spock at figuring out the psychology of an alien species, but only because Spock is portrayed as irrationally fixated on a preconceived notion about them without any evidence to support it.)
Since then, though, a lot of people have come to use it as a catchall phrase for "any guest character I don't like," or even "any main character I don't like," so the usage has blurred to the point that it's become effectively useless as a term of meaningful criticism. Which I another reason I resist defining it broadly.