We know that the U.S. has a much stronger military than the Taliban, they could have deployed more troops in Afghanistan to beat Taliban, but they consciously didn't. This makes me wonder, does U.S. troops leaving Afghanistan mean that they lost the war against the Taliban?
Yes. Unquestionably. They left their enemy in control.
Word games about military dominance in the field are besides the point in a guerrilla war. That kind of sophistry has been tried on Vietnam retroactively as well (which also "wasn't a war"). The winner is the one who outlasts the other.
Now, that is not the say US forces were ever defeated in the field. They were not. What never happened was enabling a stable Afghan, pro-Western, or at least not anti-Western government that could stand on its own, without needing military assistance from the West.
Rather than putting blame on the brave men and women of the US and NATO military, it might well be laid at the feet of Western politicians who never quite grasped what they were dealing with. Along with the difficulty of putting in place a government of Afghans that was trusted by Afghans.
"War is a continuation of politics by other means." Clausewitz. Clearly the overall political outcome has not necessarily developed to Western advantage.
So, yes, they lost.
p.s. In the larger scheme of things, leaving Afghanistan will allow NATO to refocus on its primary concerns, which mostly have to do with managing relations with China. Military gear and doctrine suitable in a counterinsurgency context has very little relevance in a peer-enemy conflict. And that's the bigger concern by far, much as Afghans risk suffering horribly under their new oppressors.
they could have deployed more troops in Afghanistan to beat Taliban, but they consciously didn't.
I don't believe that to be a valid assumption.
Extended deployments were running the US military ragged. Only a minority of troops could serve usefully (the Navy for example is of only limited utility there, carriers aside and so are heavy tank divisions). Recruitment and retention were both affected by this never-ending mission. It is one thing to fight for one's countries in a short sharp war like WW2 or Korea, it is another to be separated from your family during years of rotation, with insufficient training in between, in the ass-end of nowhere.
Also, missions like these don't happen in a vacuum. To allow for them, other theaters get stripped of materiel and personnel, budgets are slashed elsewhere, overused gear wears down much before its expected lifetime. One of the eye openers I had upon reading The Rise and Fall of an American Army: U.S. Ground Forces in Vietnam, 1963-1973 by Shelby L. Stanton years ago was how barebones critical Cold War areas like the Fulda Gap were being left to feed the Vietnam quagmire (something that must have tickled Soviet generals pink).
This is why "we coulda won, but our politicians chose not to" rings hollow, to me.
And, to @Joshua's comment, past a certain point, you can't impose peace in guerrilla wars without great human cost - to soldiers, to civilians. Maybe there was a window where the peace could have been won, early on. Later on? Doubtful.
Yes, but 'win,' 'lose,' and 'war' are word games in a case like this.
The US-led coalition invaded Afghanistan with ill-defined motives, caused regime change, fought a protracted counterinsurgency/foreign internal defense campaign in support of the regime they installed, and failed to accomplish the goals they did set themselves during much of the war.
As Ted points out in his answer, legally the US did not declare war in most of their recent wars. That wrinkle of US domestic legislation and balance-of-powers issues doesn't stop them from being wars in the sense of international law. Yet in this case, the US tried to declare some of their enemies unlawful combatants rather than POWs. They did not get too much flak over that from the international community, so perhaps it wasn't a war. Just development aid with an armed escort. All those people in battle dress were there to dig wells and build schools, right?
A facetious answer could also be that the US did win, then handed over to a democratically elected government (if you don't look too closely), which held on with US support and then lost when the US support was withdrawn. That would neatly put the victory onto the US scorecard and the loss onto the scorecard of the Ghani government.
And remember that Mission Accomplished poster? That was about Iraq, of course, which that was a different theater in the same conflict-that-could-be-called-a-war. So if you count the different theaters properly, you might find that the war is still ongoing and for that reason not lost yet.
The halfway serious answer would be that the situation is roughly back to the status quo ante, which has to count as a defeat of the side that set out to change the status quo.
This is a complicated question...
First — and technically speaking — the US was never at war in Afghanistan or with the Taliban. For the US to be at war, Congress has to declare a state of war, but the entire 20 year debacle in Afghanistan was handled under Executive powers, without Congressional action. At best we might call the occupation of Afghanistan a protracted police action, or an intervention, or 'preemptive self-defense' (to use Bush's terminology), but it was never precisely a war.
Second, removal of the Taliban was at best a secondary objective. The US initially entered Afghanistan to root out ostensible terrorist training camps in that nation. Removing the Taliban and trying to establish a US-friendly government were ex post facto justifications for continuing the occupation after the initial invasion. These justifications were necessary because Bush (and every president since) knew that withdrawal from Afghanistan would be a political nightmare. It was seemingly inevitable that as soon as US troops left, any established government would collapse and the Taliban (or some equivalent) would return to power. No president (until Biden) was willing to take the political 'hit' from the apparent failure of US objectives in the region. The war in Afghanistan continued so long mainly because it was a hot potato that each administration wanted to pass on to the next so they didn't get their fingers burned.
Third, the US really had no strategy, long-term goals, or clear objectives when they entered Afghanistan. There was never any possibility of 'winning' because there was no goal or plan to be achieved. Afghanistan and Iraq were mainly reflexive expressions of US angst over the 9/11 attacks; they were intended to display US virility and puissance after a moment of national vulnerability, and like most such displays they ended up as mere expressions of impotence.
I imagine a different outcome might have been achieved if the US had been interested in pursuing a sincere course of nation-building, creating an effective government with broad support among Afghanis. But they weren't, and didn't, and so the eventual outcome was perfectly predictable before the invasion ever began.
The answer is it's complicated.
This summarizes the prelude to the invasion:
Mr. Bush said the Taliban, which then governed most of Afghanistan, had rejected his demand to turn over Al Qaeda leaders who had planned the attacks from bases inside Afghanistan. He said he intended to bring Al Qaeda leaders to justice, adding, “Now the Taliban will pay a price.”
“These carefully targeted actions are designed to disrupt the use of Afghanistan as a terrorist base of operations, and to attack the military capability of the Taliban regime,” the president said.
The various loosely defined objectives of the invasion can be argued as successful. The goal of the invasion of Afghanistan was revenge for the September 11th attacks, i.e. to make Al Qaeda operators pay, mainly Bin Laden. The United States did hunt down many other operators of Al Qaeda and the Taliban. It also appears that the United States did hamper Al Qaeda's ability to launch attacks at the United States.
In December 2001, the Taliban’s spokesman offered an unconditional surrender, which was rejected by the United States.
After the Taliban was defeated, NATO began a new operation to rebuild Afghanistan. The Taliban meanwhile organized guerilla warfare that slowly became stronger during the rebuild. The United States changed courses many times during this rebuild with different objectives every few years.
The ongoing war between the Taliban and the United States officially reached (or began) it's conclusion following:
U.S. envoy Khalilzad and the Taliban’s Baradar sign an agreement [PDF] that paves the way for a significant drawdown of U.S. troops in Afghanistan and includes guarantees from the Taliban that the country will not be used for terrorist activities.
The following period sees the United States withdrawing while the government set up by the United States is quickly defeated often without a fight, ending with the Taliban in control of the country.
If you take into account the entirety of conflicts between the United States and the Taliban from 2001-now, the results are inconclusive. I would argue that the United States did not win or lose in its war against the Taliban. Like you alluded to in the question, it all depends on framing:
they could have deployed more troops in Afghanistan to beat Taliban, but they consciously didn't.
The United States' objective in the war was never the complete annihilation of the Taliban.
The United States achieved many of its objectives for its war with the Taliban, but it was unable to completely impose its will as a superpower on Afghanistan leading to the feeling of defeat. Adding to the fact, the United States wished to prevent the Taliban from retaking complete control of Afghanistan, also leading to the feeling of defeat. So while the results of the conflict feel like a defeat for the United States, they can more accurately be described as inconclusive.
Saying the US lost the war against the Taliban seems needlessly confusing. We already have commonplace ways of explaining what happened in a more accurate way:
The US won the war but couldn't beat the Taliban in the end. Winning the war was just the start -- the US was unable to install the government they wanted. After winning the war the US waged a long, losing battle against the insurgency. Ultimately the US lost the war (which means "yes, they won the war part, but then it was like they lost because... "). There's even the expression "won the war but lost the peace".
The point being that it's understood actual war is the high-intensity part -- the thing the military is mainly organized to do -- and also that it may fail to get what you really wanted. We have words like nation-building or counter-insurgency for the follow-up, which involve the military and probably shooting and bombing, but aren't war. Saying a war followed by an occupation counts as just a war seems like a deliberately misleading simplification.
Now, we can metaphorically call things a war, but we distinguish that from an actual war, for example "The US lost the war against the Taliban despite handily winning the actual war". We can tell the 1st use is metaphorical. If someone wrote simply "the US lost the war against the Taliban" on their English paper, you might explain war could mean two things and "struggle" might be more clear.
If you look at the American reasoning for military intervention in Afghanistan, which was to craft a sustainable, democratic nation-state, and you look at the current outcome, it is pretty clear that there was an American strategic failure. The Afghan military and police forces dissolved as the US began scaling back its military involvement, and other political institutions were not sound nor did they garner legitimacy. The Talibs also were also able to capture US military equipment meant for the now-defunct Afghan military, which the US likely could have redirected to other allies. It is also important to note that the Taliban was able to lull the US and the international community into a sense of security through publicity efforts crafted to portray the Taliban as more moderate than it was since its conception. By doing this, the Taliban was able to play the long game. They knew that their timeframe for strategic victory was longer than the US, and so they simply waited them out, and sped up the process of American withdrawal by easing up on their more unsavory agendas in the near term and agreeing to superficial peace deals with the US.