WASHINGTON — The pivot in counterterrorism policy that President Obama announced last week was nearly two years in the making, but perhaps the most critical moment came last spring during a White House meeting as he talked about the future of the nation’s long-running terrorism war. Underlying the discussion was a simple fact: It was an election year. And Mr. Obama might lose.