The problem with the war is that no one was ever willing to put in what was required to really transform the country into some western-lite clone. Early on, every one was saying you would need 500,000 ground troops to provide security and trillions of dollars to rebuild the infrastructure, economy, govt institutions, education system, etc. Of course, no NATO country was willing to come even close to that.
So for the past 20 years, US/NATO has just been trying to get by with the minimum, which was just enough to keep the place from blowing, while pretending everything was fine and there was nothing to worry about.
Best example is Opium. Local farmers switched to Opium production during the 80s when they needed quick cash to finance the Taliban war against the Russkies. In 2001 when the U.S. invaded, Afghanistan was supplying 90-95% of the world's Opium/Heroin demand. At one point, there was talk of helping local farmers to grow other crops and subsidizing the difference, but the cost would have beeen enormous and there was the additional problem that most rural areas were contested. Fast forward 20 years during which most of Afghanistan was supposedly under government/NATO control. in 2021, Afghanistan is still supplying 90-95% of the world's Opium/Heroin demand, most of which is grown in areas controlled by the Taliban. The profits of the sale of Opium are one of the main sources of financing for the Taliban.
U.S./NATO should have left years ago.