Two decades of war in Afghanistan have helped transform the spy agency into a paramilitary organization: It carries out hundreds of drone strikes in Afghanistan and Pakistan, trains Afghan commando units and maintains a large presence of C.I.A. officers in a string of bases along the border with Pakistan. At one point during President Barack Obama’s first term, the agency had several hundred officers in Afghanistan, its largest surge of personnel to a country since the Vietnam War.