Stunning advances by Taliban insurgents this summer amid an ongoing U.S. troop withdrawal from Afghanistan threaten to unwind a fragile security structure built through years of military toil in a matter of weeks, raising renewed questions about the conflict’s cost in dollars and American lives.