We got _incredibly_ lucky. A Soviet submarine trying to get through the blockade believed that war had broken out and wanted to attack the US fleet with nuclear torpedoes [0]. Normally only two men aboard the sub had to approve the nuclear launch, and they both wanted to fire. This particular sub happened to have a third officer [1] on board who also needed to approve the launch, and he may have literally saved the world by disagreeing with the other two officers.
0: https://en.wikipedia.org/wiki/Cuban_Missile_Crisis#Averted_n...
1: https://en.wikipedia.org/wiki/Vasily_Arkhipov