I just heard yet another newscast quoting Donald Trump as complaining, "We're losing in Afghanistan." This impelled me to draft a post about why we are, of course, losing in Afghanistan. When I searched my blog, I realized I wrote that post in January 2015, and as I reread it, I see it makes my points pretty well.
Briefly, a formal army cannot defeat a guerrilla insurgency fighting on its own ground, with any kind of support from the local population, so of course we're losing in Afghanistan.
For the full argument, with historical detail, I refer you to this post:
Losing the Wars