>>50197832Gen 2 used the same code as Gen 1, but Gen 3 was rebuilt from the ground up for the new GBA hardware. Some things, like the soundtrack to Gen 2 still exist on Gen 3 cartridges, presumably used for testing purposes during the development, but otherwise they more or less started over at that point.
It's part of the reason you can't trade from Gen 2 to Gen 3, things like Shiny were made independent of the Pokemon's IVs, and natures are determined by the procedure that creates a Pokemon's IVs from each Trainer's distinct seed when a new game is started.
I'm pretty sure Gen 4 onwards had a different code-base too, since they had to run on different hardware, and started to incorporate 3D graphics, but the procedure for generating Pokemon in-game and during promotional events remained the same, meaning that Pokemon from Gen 3 can be traded all the way up to the latest games and still be considered legitimate, as the rules governing what are valid combinations of natures, IVs, etc have remained constant since then.