According to Seymour Hersh's Dark Side of Camelot, the Bay of Pigs attack of April 1961 was supposed to be preceded, the day before, by the assassination of Fidel Castro. "The assumption that Castro would be dead when the first Cuban exiles went ashore, and the fact that he was not, may explain Kennedy's decision to cut his losses. The Mafia had failed [to kill the Cuban leader] and a very much alive Castro was rallying his troops." So, Hersh says, Kennedy cancelled the second planned airstrike by B-26 bombers.
Hersh also says that after the blunders of the Bay of the Pigs and then the Vienna summit, at which JFK was verbally slapped around by Khrushchev, Kennedy decided that he needed to escalate in the Vietnam War to show that he was indeed a tough guy.