The 8-bit sonic games were originally made with the Game Gear in mind. Because the Game Gear and Master System have nearly identical hardware (except for a different screen size and palette), Master System ports were made as well.
It is true for Sonic 1, but Sonic 2 is infamously difficult on Game Gear, because the levels where designed with the Master System in mind, and it didn't port well to the smaller Game Gear resolution (160x144 vs 256x192): the assets are the same size, so the effect is almost like a truncated viewport.
The SMS had an extended life in places like Brazil which led to certain Genesis titles, like Sonic, receiving ports to the SMS.