Personally, i think they have been trying to bait NATO in to fight, and not just for this reason. There have been numerous examples
Why do you think so? In my impression they clearly avoid a direct confrontation with NATO. Think there's very little speaking for that.
Sure he wants to avoid nukes because he wants. To live as much as anyone else but just like Ukraine, does he believe the world is ready to end itself over a different non nuclear nation even iff they're NATO? If not, there's little stopping him from doing to them what he's doing to Ukraine and cry 'nukes' if there's retaliation or worse still, actually use a small one to show he means business. My point is, NATO or not, is Latvia really worth ending the world for to the US just because they're NATO?
I think the key thing right here is preparation. Putin clearly exploited Europe's military weakness and seized the moment for his attack. If we just continue like that, it's very dangerous and I wouldn't put it past him to do the same to Latvia, e. g. But if the West is prepared to defend Latvia, it's an entirely different matter. It's essentially a Mexican standoff. You can't allow him to take one out without catching a bullet himself.
@Raoul said something similar by arguing it would be best if MAD would be automated. Putin is playing the opponent so it is important that it is clear which actions lead to which reactions. Make it so that pressing the red button means he's firing one on himself. Make it calculatable and don't give him room to maneuver in.
That being said, the whole situation is (logically) very hysterical right now. For Putin, Kyev is just another Aleppo or Grozny. He launched his attack talking about "unseen consequences" for anybody who would intervene and we did intervene not only by the most severe sanctions a major country has seen in modern days but also by directly and openly supplying weaponry and intelligence to Ukraine, contributing majorly to the death of thousands of Russian soldiers and probably billions of military equipment - something which in combination at least seems possible to end Putin's reign. And Russia accepted it teeth grindingly, only signaling us to not go too far. I think it's a very long stretch from going from there to "you know what, let's invade Latvia and see what the NATO does".
Think the most important part is that nowt hat NATO has finally woken up to the threat, we won't allow ourselves to be lulled in again and remain vigilant while Putin's autocracy implodes gradually. Our strength is that we are econimically far ahead of him. And if we drag this out and continue to translate this economic advantage into a technological/military one (e. g. by developing fully reliable missile defense systems and deploying them) we might even be able to eliminate the risk of Russia's nuclear threat altogether.
A dictator lives and dies based on his (projected) strength. Brainwashing his own population is one thing, but if he were to leave Ukraine empty handed after more or less humiliating his military, losing thousands of soldiers and wrecking his own economy, then I assume the people around him would get their daggers out.
The same goes for his foreign policy: I assume Nato could relatively easily stop his forces in Ukraine, but it's this image of a strong and unscrupulous leader that makes them too afraid to get actively involved.
And even this idea that he has absolutely nothing to fear about on the domestic front might be a bit naive. It sure doesn't feel like it, but we're just a couple of days into the war and the sanctions, war enthusiasm and emotions are probably at their peak. But that doesn't mean it will always be like that, once the economy deteriorates further and the coffins come home, going on and on about Nato and Nazis in Ukraine might not be so effective anymore.
I want to believe that as well but fear I'm not as convinced as you are. I don't know if Putin's grip on his inner circle is so firm that they won't stage a coup regardless of what happens, or if that is even possible to begin with (I hope not, obviously). But I have the fear that dictactors with modern technology can build such a brainwashing, surveillance and suppression machinery that it immediately suffocates even the earliest signs of revolution. And my thinking was that if the sanctions won't do the job, I have my doubts if a retreat which can be sold to the public as a finished mission and kept promise ("see, we never were that bad and just did what we proclaimed, NATO lied to you") will tips it over.