Strictly speaking, this is not really true.
What nuclear weapons have done, is deny the Aggressor Powers (herein defined as the USSR and Red China) the opportunity to force a military decision on the central theater of conflict. MAD doctrine having frustrated their desire to engage their opponents (the NATO West) in a direct engagement, it was necessary instead for them to pursue their expansionist goals by the prosecution of "proxy wars" in peripheral theaters (Korea, Vietnam, Afghanistan).
I am not saying that this is in any way a "bad thing". Nuclear Weapons have fulfilled the primary goal of any Republic, which is to defend its own citizenry from external aggression.
But having given nuclear weapons this credit, we should not pretend that they have "prevented war" (the swift conclusion of WWII against Japan being the only real example I can think of in that respect). Rather, they have redirected wars. But they have certainly not "prevented" them. As a matter of objective history, the latter half of the Twentieth Century has run red with the blood of millions killed in these vicious little non-Geneva-Convention "proxy wars".
That's simple fact.
Now you can go where people are one
Now you can go where they get things done
What you need, my son... What you need, my son...
Is a holiday in Cambodia
Where people dress in black
A holiday in Cambodia
Where you'll kiss a** or crack
Pol Pot, Pol Pot, Pol Pot, Pol Pot...
And it's a holiday in Cambodia
Where you'll what you're told
A holiday in Cambodia
Where the slums got so much soul
-- "Holiday in Cambodia", The Dead Kennedys, Give me Convenience or Give me Death
I'll credit nukes for keeping these wars off our shores, no question.
But not for "preventing" War. They have done no such thing.
Thanks bunches, OrthodoxPresbyterian.