I know it sounds too simple but….
FOH….US spent twenty years in Afghanistan. WTF was it supposed to do, stay forever? US supplied tons of equipment and even trained the Afghan army, only for it to fall to the Taliban in a few days.
Difference between Ukraine and Afghanistan is, the people in Ukraine are actually fighting for their country’s survival, with or without NATO/US troops on the ground.
The Taliban was too imbedded in Afghanistan, through culture and religious ideology for the people there to even want to put up a fight.