The numbers you're quoting are in open conventional warfare. As I already said, the US dominates in that arena. Yes, the US was able to push out the Taliban when they were an organized fighting force. However, once that finished, it became fighting Taliban insurgents, where the US did not find similar successes. And no, the US did not drive out every Taliban insurgent to Pakistan. They were continuously fighting Taliban insurgents for 20yrs in Afghanistan, not in Pakistan.
Also, in regards to oyur stats, the US lost a lot more than 2,500. The government only publishes casualties of American military personnel. A significant portion of the US presence in Afghanistan is from private contractors (aka mercenaries), and their deaths do not get published because they are not technically part of the military. It's actually a big reason (though not the only reason) why they hire contractors - they want to downplay casualties to the American public.