America’s ill-fated wars in Iraq and Afghanistan gave the U.S. armed forces more than two decades of vital counterterrorism experience—and they continue to put this training to good use.