How is someone who starts out broken and beaten, at the bottom of the social world, about to give up and abandon all of his morals and dreams, but who slowly, and methodically improves himself over time, with the help of friends and allies, cleaning himself up and struggling with the addictions he has, and eventually making his own life, and the life of those around him better.....a Mary Sue?
He earned all that stuff he got, aside from the wealth from marrying his wife. His promotions were for services rendered to the city and the realm. For defending the people from threats, which was his sworn duty. He didn't want the promotions or titles or any of it, so it's not like he sought them out.
Also him picking up supernatural powers? What are you referring to specifically, because I'm drawing a blank on this one. Granted it's been years since I read those books, but the closest I can think of to him having a power, was in....Snuff? I think? It's the book where the subplot for him was he will ALWAYS read to Young Sam at 6oclock. And he does so via some strange methods in that book. Or was that in THUD? Is that what you mean? I'm genuinely curious what powers you say he's got, because I don't really recall any.
But, really, that's hardly a criticism anyway in Discworld, as that setting actually has Narrative Magic, that impacts like, everyone. So random characters in a Narrative, suddenly doing crazy things Because Narrative Demands, is hardly new, or unique to Sam.
But yeah, I fail to see how a character becoming stronger through trial and struggle, and growth and effort, over the course of YEARS and decades, is a Mary Sue. That's not Mary Sueness, that's simply a character arc.