They defeated American troops in several battles, but that's irrelevant. They won the war and that's what matters. The Taliban are now back in power. America jumps into wars for the wrong reasons hence they lose. You fight wars you can't win. Wars to fill the coffers of the military-industrial complex. What was the end game for Afghanistan? There was none. You lost the war from the very beginning and now the Taliban are back in power.
I can beat you in a fight, by simply standing there and taking the hits. I don't strike you, I just absorb your strikes, until you get bored and leave. Another tactic is that I move around the ring, and I let you follow me and punch the air, missing me, until you get tired. In Vietnam the Vietcong and North Vietnamese Army applied a strategy of gradually wearing down its more powerful enemy. Guerilla warfare involves wearing out (physically, psychologically, politically..etc), a better-equipped enemy until they collapse or quit. If you manage to accomplish that, you have won the war, it doesn't matter if you took in more casualties.
Soviet Russia in WW2 applied a "scorched earth" tactic, of destroying everything, to leave their enemy with nothing to operate from. No structures, no water, no electricity, just rubble. Then they were shelled to oblivion. After that, the red army would come in and fight the nazis who were left, in close urban combat. It was brutal. The Soviets won the war, despite their heavier casualties and destroying like 70% of their infrastructure.
America is going to fall apart soon, due to people like you. You right-wingers are destroying America, along with the liberals. You're ensuring the balkanization of the US sooner than later, due to both your foreign and domestic government policies. Americans are destroying their country, due to their lack of common sense and solidarity with the rest of humanity. This country has at the very most maybe 20 years, before it completely collapses economically, socially..etc. At best 20 years.