Honestly, characters like Carol Danvers aren’t Mary Sues. But in the sense that whereas fanfic Mary Sues are loved and arguably this treated well from the get-go to the end in a way, Carol Danvers was often a punching bad until recently. If you’ve got a character who’s been underestimated and mistreated for so long that it’s about time to treat them nicely.
That’s not to say Mary Sues aren’t always treated nicely, flawless or whatever but there’s an air of idealisation (that’s if such a character’s supposed to represent the fan) that escapes Carol Danvers. Danvers, to my knowledge, wasn’t meant to be a fan and had lots of problems like alcoholism before. Not only that, she was also treated badly.
This isn’t because I like her but because I don’t think she’s a Mary Sue at all.