NATO creeping right up to Russia's borders is basically poking the bear. It forces Putin to push back hard, raising the odds of direct clash.
It also handed Putin the ultimate domestic propaganda tool to consolidate power. Nothing unites a country faster than pointing to a Western military alliance literally at the gates.