I've heard this "analogy" brought up several times in the last couple days, but I just don't find it persuasive or similar, or really actually matter.
If Mexico decided to invite the Russian army in for whatever reason, that is their choice as a sovereign nation. I (as an American) would be super worried about that, but I would also think that the US should probably be asking itself why Mexico had chosen to do this instead of allying itself with the US.
And that's really the heart of this for me: despite Ukraine's history with Russia, they seem to feel that joining NATO is better for their security and safety. Russia should take a hard look at themselves and ask why that's the case, and maybe adjust their behavior so they'd be considered a more trustworthy partner.
But of course that would never happen; instead we have a dictator who believes Russia has some natural right to Ukraine's lands, and will take it by force if necessary. If the US were behaving that way toward Mexico, I absolutely wouldn't blame them for looking for outside help. It would be irresponsible for them not to.
And you don't have to imagine, just remember Cuban missile crisis (in response to US deploying missiles in Turkey, Italy)