At least in Civilization:
[. . .] Gandhi tends to be the first to use nuclear weapons, and spares no expense on wiping your civilization off the map. You probably always thought you were crazy — how could a series that prides itself on historical accuracy portray Gandhi so wrong? Well, you’ll be happy to know that both your sanity and Civilization’s historical integrity aren’t at fault. Instead, a bug’s to blame.
In the earlier Civs, leaders are given a set of attributes that dictate their behavior. One such attribute is a number scale associated with aggressiveness. Gandhi was given the lowest number possible, a rating of 1. However, when a civilization adopted democracy, it granted a civilization -2 to opponent aggression levels. This sent Gandhi’s rating of 1 into the negative, which swung it back around to 255 — the highest possible rating available, and thus, the infamous warmonger Gandhi was born.
And they just left it in there as an homage:
This cyclical aggression scale was fixed in later versions of the game, but Gandhi wasn’t totally cured of his bloodlust. The team fixed Gandhi’s aggression rating, but as an Easter egg paying homage to the earlier aggressive versions of Gandhi, ramped his nuke rating through the roof. So, while it may be difficult to push Gandhi over the edge, he goes from zero to nuclear option once you do.