In the original Civilization game, Gandhi had the lowest aggression rating in the game, 1.
However when a civilization adopted Democracy, the aggression rating would be reduced by two, making Gandhi's aggression rating underflow to 255. This, being the highest aggression level possible, resulting in a very nuke-happy Gandhi.
This was obviously taken into consideration for later Civ games. But since it was, let's face it, rather hillarious, elements of the bug has been kept in later games. For example in Civ 5, while Gandhi is generally set to be peaceful, his "nuke production" and "nuke usage" trait ratings are both set to 12, even though the maximum is supposed to be 10.
So it is not a bug (anymore). It's a feature!