The seeds of the humiliating American withdrawal from Afghanistan were laid shortly after the post 9/11 US invasion of the country. When it refrained from confronting Pakistan over its continued support of its Taliban proxy.
Afghanistan has proved once again that even a superpower cannot win a war against a proxy as long as it refuses to confront the power that supports it. This is of vital importance to Israel, which is facing a proxy war being waged against it by Iran via its regional proxies Hezbollah and Hamas.
Pakistan made a great show of abandoning the Taliban after 9/11, but after realizing that any attempt to confront US forces would be suicidal and could spell the end of Pakistan’s vital alliance with the US, the Pakistan military convinced the Taliban to retreat without a fight to Pakistan, where, under ISI supervision, they were allowed to set up camps and training facilities.
This is not the first time the US has lost a war against a proxy by refraining to take any meaningful action against the power behind it. The most obvious case is Vietnam, which was a Soviet proxy.