I think it is legitimate to have NATO being a concern for national security. No powerful country would willingly allow a hostile military alliance in its border. And while it may be true as SSU says, that NATO was not the only thing that motivated Putin, it clearly was a cause for concern - for decades in fact.
"Existential threat" is perhaps used to frequently, as I don't think NATO would reach for nukes
immediately even if Ukraine were a member. Nevertheless, it's a massive risk that could lead to the destruction of the world - hate to harp on the same point, but, that's how I see it.
So there's that one issue. Other threats are much less severe, Chechnya, internal dissent and so forth. Not existential in terms of the country being gone, but in terms of the Putin regime losing legitimacy if enough dissent occurred.
How to avoid a war? It's a bit tricky. Forgot who said this, and I'm going to probably phrase it badly, but, after a certain point, it can no longer be avoided. What that point is, is obscure-ish in terms of timelines.
I mean, how many ways do you tell the "West" that you will not tolerate NATO on your border before things go badly? The "West" is not used to countries refusing to take orders. Hence the hate of China too. It's not because of "authoritarian regimes" (which they are), it's because they don't follow orders.
Saudi Arabia, Turkey and Brazil are very authoritarian now, the West doesn't really care about them, they're obedient (mostly or by and large).
So, having said all this. Taking these two regions somehow and saying, if you send troops to Ukraine, we will invade the whole country, might have made this go a bit differently.
Or maybe not.
A full scale invasion is just the very last option that should have been pursued.