The US war in Afghanistan cost about $2.26 Trillion over 20 years, or about $113 billion per year, on average.
US aid to Ukraine is around $54 billion for the first year.
Further, both Afghanistan and Iraq were part of the so-called War on Terror which cost us around $8 trillion over 20 years, or $400 billion per year, on average.
Our aid to Ukraine comes nowhere near to those numbers, but if we lose Ukraine, then Vlad the Invader's next invasion will cost us vastly more in our own blood and treasure to defeat.