WASHINGTON — As the Afghanistan war wound down, the C.I.A. had expected to gradually shift its primary focus away from counterterrorism — a mission that transformed the agency over two decades into a paramilitary organization focused on manhunts and killing — toward traditional spycraft against powers like China and Russia.