Actually, Nuclear Gandhi is a bug from CIV1 that became a feature in later games. As Vrach said, all leaders had stats for things like aggression, chance of using nukes, expansionism etc. Gandhi in CIV1 had nukes and aggression on 1 or 2 (most of the others were somewhere around the middle between 1-10). Then, adopting Democracy (along with bonuses to science et al.), reduced a players aggressiveness. But, due to a glitch in programming, Gandhi didn't go to -1, but to 255. So, he was a peaceful, if expansionist, player. Until he discovered Democracy and just started doing everything in his power to get nukes and use them. The devs were so amused by the idea of a genocidal Gandhi that they just stuck to it in later games.
OT: you cannot (and should not) be every AI's friend. As said earlier, befriend everyone once, then leave them to their own devices. Every civ is ever looking out for #1, and that is not you. They *will* eventually turn on you, whether that be by fighting, trying to beat you to a science/culture victory, or just being passive-aggressive douches and denouncing you every chance they get.
Do not expect gratitude for anything you do for them. In my last playthrough, I (as Bismarck) had the Netherlands and Sweden as neighbors. William of Orange was an uppity shit since the Classical Era, and Gustav Adolf was kinda hanging on to him, thinking him the safer bet (the fool). Then Babylon sweeped in from the east and took all but one city from the swedes while William watched. I decided not to wipe out the last Swedish colony (near my capital). When, 500 years later, I beat up the Netherlands and made them give me a former Swedish city William had taken from the Babylonians, I gave that back to the Swedes. Which only made them be even worse little shits.
Moral of the story: if you have something you don't need, burn it rather than giving it to someone else.