One of the most difficult aspects of the fighting in Afghanistan is that, even more so than in Iraq, everything is for sale. Thus captured terrorists are often able to bribe their way out of jail. This was much less the case in Iraq, where the Iraqi government was not strong enough, until after 2007, to handle a lot of the prisoners. So the U.S. just locked the bad guys up. This kept known terrorists off the streets, and discouraged others from becoming terrorists. As in Afghanistan, most of the terrorists (as in planting bombs and shooting at American troops or fellow Afghans) were doing it for the money. Afghans, in particular, have a warrior culture that includes an acceptance of fighting a powerful force that is not harming your tribe. "Run away and fight another day" is another rule Afghan warriors respect, and practice regularly. But with an economic incentive, Afghans will get involved, despite the horrendous losses (foreign troops kill 10-20 of the enemy for each soldier they lose.)
However, Afghanistan now has a government, at least on paper. There are Afghan police and courts, and the Afghans expect captured (by foreign troops) Taliban or drug gang members to be turned over to the authorities. There, the prisoners have an opportunity to arrange a bribe, or some other consideration (like their boss promising not to kill the police commander, or his family). The bad guys walk, and the troops sometimes capture them again, or kill them.
Welcome to the Wild West, where there is no law.