There's a nice timeline here [1] of relations between Ukraine and NATO. It's an archived version from the day before the invasion began, so there's no hindsight posts. Things were accelerating rapidly on the Ukraine-NATO front. In January 2022 there was apparently even a bill that was to be introduced in the US declaring Ukraine a "NATO+ country" immediately. And NATO's responses towards Russia's expressed concerns began to be completely dismissive with not even a vague allusion to reconciliation.
So I think the main goal was certainly to prevent Ukraine from joining NATO, but I think a major secondary goal was for Russia to make it clear that their claims of red lines and such are not toothless. If a country makes repeated claims of things being a red-line but never acts on such claims, then their future claims will be casually dismissed.
[1] - https://en.wikipedia.org/w/index.php?title=Ukraine%E2%80%93N...