One of the luxuries of being an empire is that you seldom have to fight a war. Instead you buy proxies to do the fighting for you. Being an empire is mostly about skillfully spending money. The imperial way of fighting for the US in Afghanistan would be to buy most Taliban commanders and to buy some treachery to undermine the rest. That instead the US finds itself in a war that looks hard to win means that something is seriously wrong.
One problem the US has is a lack of knowledge. There are hardly any people who speak Pashtu or Persian in the state department, the CIA or the Pentagon. The result is inferior intelligence that has led the US to attack groups of people who had been falsely accused of being Taliban or Al Qaeda. It has also led to a flawed policy of investing money in Afghanistan. The logical policy would be to invest a lot in good roads. That is what the American military needs, but it will also improve the economy and provide the Afghans with money for other improvements. Instead the investment in roads is seriously flawed, with US firms getting the orders and then subcontracting it to Turkish firms who subcontract it to Afghan firms. A lot of money is wasted this way. But the most serious problem is that this lack of knowledge makes it difficult to discern enemies from friends and to get an accurate view of those somewhere in between.
Another problem arises when someone else is spending money to undermine your imperial plans. If you can't stop him you have a problem. That happened to the US in Vietnam, to Russia in Afghanistan and is now happening to the US in Afghanistan. In Afghanistan the money is coming from Pakistan, Saudi Arabia and the Persian Gulf states. All those countries are officially America's friends. But with friends like that, who needs enemies?
If you have a close look at America's friends they are all dependent on the US. The US doesn't like too independent friends, specially not outside Europe. And so it prefers the Saudi royal family above a more democratic regime that puts the interests of the people first. Given their precarious power position in their countries these "friends" get considerable freedom from the US for US hostile policies.
It could be otherwise. The US could build relations with Iran, by far the strongest country in the region. Sure, they would occasionally have to do some arm twisting and they will have to accept some policies that are not very US friendly. But together with Iran the US would have a much better chance of stabilizing the region. Not because Iran is now so harmful to US interests now (it isn't), but because Iran's knowledge of the local setting could be combined with US money.
Iran has now a bad name as "sponsoring terrorism". But when one considers how they have improved the life of the Shiites in Lebanon they certainly had a point. And their support of Hamas has finally forced the PLO to do something about its corrupt inefficiency. Compare this to China's policies towards North Korea, Pakistan, Burma, Iran and several countries in Africa that create much more fundamental trouble. And Iran may support some Shiite minorities. But should we really complain given that we ignore the "ring of fire" of Saudi sponsored insurrections by Muslim minorities around the world? So our problems with Iran are not larger than what we find acceptable with other countries. And if we build better relations with Iran we may get them to give up or ameliorate at least some of the policies that we don't like.
What is stopping the US from this? Basically, hubris and Israel. Hubris tells the US that it doesn't need anyone and that relying on really independent allies would be a sign of weakness. Israel believes that beating up any Muslim who resists is the only plausible option towards a culture that despises signs of weakness.