The case basically explodes in the chamber.
Yeah, that's how firearms work.
When the gun and the cartridge match, the diameter of the projectile is slightly larger than the barrel bore. For example, a .357 magnum cartridge is .357 inches, stuffed into what's ostensibly a .35 caliber gun. Gunpowder isn't an explosive, it actually burns very slowly. It's this very small size difference that allows pressure to build and create the chamber pressures advertised on the ammo box.
Of course a shotgun receiver can't withstand the same pressure as a .50 BMG receiver, but that's not what I said. I said a .50 BMG cartridge won't create enough pressure in a 12 gauge receiver to damage it.
But, by all means, don't take my word for it. There are plenty of videos of other people doing it and explaining it. Watch one of those instead.
Extraction and cycling are a whole other story, I'm not referring to that. 12 gauge shells are rimmed, .50 BMG is rimless, of course it probably won't cycle in most shotguns.