That's Sonic & Knuckles — the cartridge with the lock-on slot on top.
Plug Sonic 2 in and you get Knuckles as a playable character in that game's levels. Plug Sonic 3 in and you get the complete experience the two games were originally meant to be.
The lock-on gimmick was a workaround. The developers couldn't hit the deadline for Sonic 3, which was intended to ship with Knuckles playable and all the Sonic & Knuckles levels included — the level select in Sonic 3 still shows slots for stages that only exist in the second cartridge, and the sound test contains their music.
Time constraints forced the split: release Sonic 3 with what was finished, keep working on the rest, add the Super Emeralds, and use lock-on to join them back together. Sonic 2 had hit similar problems earlier, which is why the original Hidden Palace Zone and several other stages were cut.
It's one of the great bits of hardware improvisation in the era — two cartridges bought separately, one game once combined.