What was Ukraine supposed to do? They were an independent country where a larger, more powerful neighbor was fomenting a civil war within its boundaries. By the way, its predecessor, the Soviet Union, destabilized governments in a similar way across the world during the Cold War. The US and Great Britain had made it clear that they would not honor the implied commitments of the 1994 memorandum. Therefore, like almost every other Eastern European nation, it seized upon NATO and EU membership as its only possible security guarantee.
Seeking such security guarantees hardly excuses Putin's brutal invasion, an invasion, by the way, that has added nearly a thousand miles of NATO border to Russia in hiking distance of St. Petersburg (Finland) and turned the Baltic into a NATO lake (Sweden and Finland). Strategic brilliance on Putin's part.
Of course Ukraine is continuing to fight - just as I pray we would were the PRC to occupy 20% of our country on the West Coast. Every Russian they kill puts additional pressure on Putin to make concessions in any negotiation - at least it did until Trump seems to suddenly support Russia and its aims.
No nation will want to provide a bilateral agreement to defend Ukraine against renewed aggression. The simplest way to provide them with a collective security arrangement is simply gran them NATO membership.