The United States signed a deal with the Taliban on Saturday that sets the stage to end America’s longest war — the nearly two-decade-old conflict in Afghanistan that began after the Sept. 11 attacks, killed tens of thousands of people, vexed three White House administrations and left mistrust and uncertainty on all sides.