As far as I am aware, both sides knew that if they attacked first the other side would fire back with just as devastating consequences. Why would they bother even considering launching a nuclear attack with this knowledge?
The Soviet Union and United States never considered nuclear war a viable way to end the conflict; as you mentioned, any attack would result in mutually assured destruction (MAD). It wasn't the actual act of nuclear war that the two superpowers found viable, it was the threat of attack. In theory, the threat of nuclear attack could by used by one of the superpowers to prevent or dissuade the actions of the other. For example, the threat of nuclear attack from one superpower could deter the other superpower from launching a nuclear attack.
This idea of was part of deterrence theory, which was an incredibly popular strategy during the Cold War. The deterrence policy of the United States changed as the country shifted from containment to détente, but the basic idea remained the same; dissuade or prevent the Soviets from performing certain actions. Ultimately, both superpowers found themselves in a Nash Equilibrium due to deterrence; neither side, once armed, was capable of launching an attack because there was no incentive to do so; destruction was mutually assured if an attack occurred, which would result in a negative payoff for both sides. This created deadlock, which resulted in the Soviet Union and the U.S.A turning to proxy warfare rather than directly confronting each other.