In my opinion the problem with Afghanistan is very, very simple*.
In many conflicts when the strategy shifts from "winning" to "not losing" losing is pretty much the end result. Whether you study history or just apply the concept to your home game (whatever it may be) it's a startlingly obvious thing to those who never noticed it before.
Original objective: Destroy AQ there and depose the Taliban for harboring them. Accomplished. The two moved across the border and at least the Taliban are literally taking a page from the Vietnam War lesson and using the artificial border as a refuge to continue it's insurgency to regain power in Afghanistan.
Meanwhile it seems the US has adopted a "don't lose" mentality against the cross border insurgency.
The current administration claims the operation that took out Bin Laden was the most audacious plan in 500 years... despite the fact that Biden was opposed to it and the POTUS was essentially cornered into making the decision and took what, like 10 hours plus to greenlight it? It's easy to be snarky about that comment. Anyone who has any grasp of history can tear it apart, but really it was a political statement meant o play to the stupidest of the O's/Biden's political base.
The war in Afghanistan will be won in one of five** ways:
1. The US packs up and leaves, claiming "Victory with honor" as we did in Vietnam. This allows the Taliban to become resurgent and try to take over on heels of claiming they drove out the invader etc. I won't predict a Taliban "victory" since their odds go down the longer we stay there, in my opinion.
2. The US stays for another twenty something years, vigorously applying counter insurgency measures etc and eventually the Taliban support dries up and they cease to be unless propped up by other outsiders...
3. The US decides Pakistan is a failed state, isolates/captures/destroys Pakistan's nukes and applies the same treatment to Pakistan it gave to Afghanistan for harboring AQ (and this time also harboring the Taliban). Move US Forces from Afghanistan into Pakistan. (not the best option in my opinion)
4. Pakistan decides it is time to clean house and "invites" the US to clean out the Taliban and AQ hiding in Pakistan... this could bring out the fanatics to "fight the infidel" and allow them to be reduced in power if not eliminated for decades by Pakistan. Of course it would mean a civil war for Pakistan but the perfect idea in this sort of thing is a rare thing.
5. The US and Allies cripple Iran's nuke program, destroy Iran's export capability, destroys Iran's economy somewhat and essentially destroys Iran's ability to export terror both financially and logistically. Import into Iran real support for an insurgent action against the Mullahs and apply similar tactics to any other country sending support to the Taliban as needed until they have no money to pay people and no imported weapons/munitions/logistic to add to the fight. Eventually they will dry up and be in the dustbin of history. hOpefully regime change could be ironically brought to Iran without an invasion.
6. A meteor hits Pakistan turning the region into lava. Depending on the size of the space rock the rest of us might/might not consider a victory in Afghanistan a priority at that point.
Personally I'm all for #4 with a good healthy touch of #5. #2 is the next best if we could apply some of #5 along with it to cripple the logistics of the enemy.
Note that none of the above include "nation building". In my opinion Nation building is something that the people of the Nation mentioned need to step up and do because they want to. We can set the example but people tend to get into their mindsets because of how they have lived and those attitudes/mindsets are hard to change once they are set. If we go with option #2 and stay AND educate the next several generations of Afghans then they *might* have a mindset that steps above tribalism/corruption/religious intolerance. No guarantees.
Note that none of the above includes "put someone in charge in the US who wants to win" etc... I'll point it out here for those who need it said: How can we expect to have a winning strategy of any sort when the person(s) running the show at the top levels didn't want the war in the first place and have a history of saying wars can never be won if the US was looking at being involved in it?
The current empty suit of a President, before he ran for POTUS and when he was running kept saying the real war was in Pakistan. But that changed when it's perceived as politically inconvenient and offensive to his base to expand the war effort once he's in charge. Wars can't be won this way, but the can be lost or prolonged.
*and yes, lots of it can be very complicated on local/operational level etc.
**#6 isn't really a win, more of a cancelled/draw due to natural disaster...