As the other poster mentioned, Ukraine and Georgia were both denied Membership Action Plans at the 2008 NATO Bucharest summit, meaning they weren't even on the first rung of the process to join NATO. In 2021 NATO made some positive noises but still refused to offer Ukraine a MAP, even though Russian troops were massing on Ukraine's border.
It also takes years to be able to join after a MAP starts, and most importantly a MAP is not a treaty with any legal power: Joining one doesn't guarantee membership and the process can be stopped at any point. So even while Russian troops were massing on Ukraine's border and threatening to invade NATO wasn't ready to formally move closer to a Ukrainian accession beyond some encouraging words. Nearly all of the military support to Ukraine came after it was invaded, not before, and it was committed because NATO quite understandably reasoned that if Russia was willing to invade Ukraine without legal justification or provocation it would not stop there, but would try to go for Moldova and other countries next, significantly changing the strategic picture of Europe for generations. Supporting Ukraine is a defensive action.
The idea that Ukraine joining NATO would've meant US 'missile banks along the Russian border' is ridiculous, given that none of the other NATO members that border or are near Russia received US missile banks. As I said, NATO was very careful to limit both the quantity and type of equipment that it would deploy in new members, restricting them to purely defensive measures such as the NATO air patrols over the Baltics.
Putin has also quite clearly stated on numerous occasions that he considers Ukraine statehood a myth and that it's really a breakaway province of Russia.[0]
Finally, even if Ukraine was about to join NATO, that gives Russia no right to invade it. I don't understand why you seem to believe that it would.
[0]https://time.com/6150046/ukraine-statehood-russia-history-pu...