How was Bay of Pigs not considered an act of war?
Was it an act of war? Of course, it was. The only fig leaf was the alleged deniability — the CIA had tried to make it look like it was some kind of action waged exclusively by Cuban exiles to retake their homeland, but the logistical support was very clearly American — and the fact that the US had not chosen to get more directly involved (Kennedy did not send in air support, which would have been more brazen and existential for the Cubans).
It was not much of a fig leaf and neither the Soviets nor the Cubans considered it to be anything other than a militaristic, expansionist, hostile act by the United States. They definitely considered it an act of war!
But what was preventing them from attacking the United States? How about: If the Soviet Union attacked the United States, that would escalate the conflict and possibly lead to the deaths of hundreds of millions? Or: If Cuba attacked the United States, it would totally and utterly be defeated? Neither of those are very good options.
Thus, as with many things in the Cold War, an uneasy truce was kept, one that played out in proxy battles and not major escalation. (They complained to the United Nations, for what good that did. It was very embarrassing to Kennedy, to be sure, and the US reputation took a hit for it. But there is a gulf of difference between “very embarrassing” and “all-out declaration of war.”)
The real response, in the end, was the decision to put nuclear weapons in Cuba — both on the idea that this would make any incursion against the island an unquestionable act of escalation by itself (and thus, ideally, deterring it), and on the idea that tactical nuclear weapons there would actually give the Cubans the ability to fight off an invading US military. (And other reasons for putting them there. Nukes in Turkey. Making Castro happy. Trying to negotiate over West Berlin. We don’t want to make it sound like Bay of Pigs was the only reason. It wasn’t. But it was part of the overall context.)
Obviously, that didn’t exactly deescalate the situation, as it led to the Cuban Missile Crisis which almost got the aforementioned hundreds of millions of people killed. However one of the resolutions of the Crisis was the promise by the United States that it would never try to invade Cuba again, thus not incentivizing further Soviet efforts to militarily reinforce the island nation to such a degree.
The Cold War is full of these kinds of feints and near-misses. One can ask the same thing about Soviet supplying of North Korean forces in the Korean War, Chinese supplying of Communist forces in Vietnam, American supplying of mujahideen forces in the Soviet-Afghan War, and so on. Being willing to sort of look the other way in what under any circumstances could be interpreted as larger acts of war was, ultimately, an act of self-preservation.
The Cold War was a very delicate kind of dance in many ways, trying to achieve various diplomatic and military ends while also trying to avoid an escalation that would lead to mass destruction.
There are many good books on this period and the run-up to the Cuban Missile Crisis and the like. Michael Dobb’s One Minute to Midnight: Kennedy, Khrushchev, and Castro on the Brink of Nuclear War does a good job on the context and is very readable.