If your goal is to prevent NATO expansion, the Ukraine invasion makes no sense. In its wake it has caused multiple neutral countries to explore membership (Finland, Sweden) and has caused an otherwise austere Germany to increase defense spending. It has also laid-bare problems in the Russian military on the global stage. Massive unforced error.
The counterfactual where Russia never invaded Ukraine in 2022 or 2014, we'd still be talking about leaving NATO - something Trump was floating in 2016. There were rumblings about dissolving it prior to these actions. If Putin had simply waited, further entangled Europe into its fossil fuel industry, and continued overtures to western right-wing parties, he could have probably eliminated NATO as a "threat" to Russia within a decade. Without a single shot fired, without a soldier stepping foot on foreign soil.
[1]https://www.nytimes.com/1991/12/21/world/soviet-disarray-yel...