The US military itself is a weapon - and that weapon is only as strong and effective as the will of the one wielding it. There was no will to "win" in Afghanistan, to a large extent because nobody had a clear understanding of what that even means. Hence the withdrawal, which is a political defeat. But militarily, you only need to look at the casualty rate to see who had the upper hand in fighting proper.