The problem with "Mary Sue" is that it's become so broadly defined as to be practically useless as a term of criticism. Fans basically use it for any character they find unappealing or excessive. So I'm not sure it's useful to approach the question in those terms. If you worry about whether someone will label a given character a Mary Sue, you'd never get any writing done, because there's bound to be someone who sees them that way.
There's a perception today that any guest character who steals the spotlight from the leads is automatically a Mary Sue, which is why you hear the charge leveled against Piper in Dreadnought! and Evan Wilson in Uhura's Song. But the fact is, it was common in episodic TV from the '50s through '70s to aspire to an anthology-like approach -- to have the regular characters travel from place to place or move from case to case and thereby get acquainted with the guest characters and their problems which would be the focus of each week's drama. TOS itself did this to an extent, at least initially -- focusing on Mitchell and Dehner in the second pilot, Harry and Eve in "Mudd's Women," the Romulan Commander in "Balance of Terror," Charlie in "Charlie X," etc. In the end credits, the central guest stars were billed above semi-regulars like Doohan, Takei, and Nichols, because the paradigm of '60s TV gave so much importance to the featured guests.
And of course in modern Trek Lit, we have cast changes and story evolution that leads to original characters being added as new regulars, not just guest stars. That's just the same kind of process that led to Chekov being added to TOS, Pulaski, Guinan, and Ro to TNG, Worf, Winn, and Damar to DS9, etc.
So a guest star taking the spotlight is not automatically a Mary Sue -- it's just a common trope of episodic storytelling from the era. A Mary Sue is that trope done badly. So basically what you're talking about is just the difference between writing characters well and writing them poorly. The mistakes that produce Mary Sues are the same ones that produce bad characters of any sort -- self-indulgence, unnatural characterization, making characters too perfect or one-dimensional, telling rather than showing, etc.
So avoiding favoritism is just part of generally trying to write reasonably well. There's nothing intrinsically wrong about a character dominating a story if it works, if there's good reason to focus on them, and if the other characters aren't mischaracterized in order to let the character in question dominate without deserving to. Ultimately, I think we just try to focus on making the story work the way it needs to, and letting the characters evolve and interact naturally.