Putin sees it differently, although I don't know enough to say if he's correct.
He said about a fortnight before the invasion that if Ukraine gained NATO membership, along with its recent military overhaul, it is possible Ukraine would be emboldened enough to attempt to recapture Crimea. He feared that in this situation, they could invoke article 5 when Russia started bombing Ukrainian airfields in response.
This scenario would put NATO in direct conflict with Russia with Ukraine having "started it" (which is a bit rich since Russia annexed Crimea in 2014).
Regardless, in that very specific scenario he claims to see NATO as a threat, or at least a NATO backed Ukraine. There are a few holes in this theory though, would Ukraine really attempt to take Crimea and expect NATO backing if they gained membership? None of us can really say, seems unlikely on the face of things. Second, what does the current invasion of Ukraine actually achieve in regard to the theoretical scenario Putin described above? I can't see it making any difference unless Russia takes Kiev and installs a puppet government, one that allows them to retain a constant military force in Ukraine. Or maybe they hope that as part of the peace treaty, Ukraine pledges never to join NATO. I digress, but Putin has given reasons as to why he considers NATO a threat - that effectively it embolden his enemies. Whether this is true, or even if he actually believes it, we'll likely never know.