Like NJ said, many games are hacked from within the actual cartridge of the game. Most Hacks can be done with open-source software, but Chaos Black was made purely by extracting and editing the game's C++ and C# coding.
Other fangames can be made with game-developing tools like RPG Maker, Game Maker, Multimedia Fusion, etc. However, these normally take longer, despite needing less technical knowledge.