I say "a device" because I'm not convinced that this happens on an actual Game Boy. (I haven't been able to provoke it on mine yet.)
I've seen several videos of people showing how their Analogue Pocket (modern FPGA Game Boy "emulator" device) hangs (or maybe it's the game itself that hangs?) if you even touch the inserted cartridge while running the game.
The Analogue Pocket has, seemingly for (dubious) aesthetic reasons, made it so that an original Game Boy cartridge is barely held in place on the back of the console, with almost nothing of the cartridge "covered" physically, unlike the original Game Boy into which you slide the cartridge and it's physically held in place tightly.
Most of the time, why would either the game or the console care at all about briefly losing electrical connection with the ROM? Surely data is not constantly transferred to and from the cartridge? Only when loading a new level or starting the game and things like that? Otherwise, the device has the data in its own working memory, no?
Why would briefly losing electrical connection with the ROM cause it to immediately freeze/hang/glitch out when it's not even trying to retrieve data? Why would it even be aware that this has happened?
PS: I tried to search for one of those videos that I have seen to link to it here, but just can't find anything when I need it.