Wasn't US training that failed the Afghan military. Coalition-trained Afghan special forces often performed well. The Afghan military's problems were... numerous. Ghost soldiers, low control of units by the national government, rampant drug use, regional loyalties, poor morale, low pay, etc etc etc etc.
In many ways it failed in Ukraine as well. Our tactics are/were created for our military, with our firepower and assume air superiority. That does not exist in Ukraine. Our methods were getting their fighters killed, so they adapted and devised their own.