Modern Vintage Gamer recently posted a video about how the Game Boy Advance knew when a Game Boy / Game Boy Color game was being inserted. The quick answer is GBA carts toggle a physical switch that enabled GBA mode, however this video goes into detail about the software side of things…including how GBC games could run in “GBA Enhanced modes”, even when the GBA mode was toggled.
Support MVG here: https://www.patreon.com/ModernVintageGamer
As a note, the physical switch issue is also why a ROM Cart like the GBA Everdrive can’t run in a GBC mode: While technically you could make a cart with pins on both sides, or even some complicated mechanical toggle, this would result in a product that’s far more expensive and don’t look anything like an original GBC/GBA cart. There’s also the voltage issue to deal with and while that’s solvable, it’s yet another cost. It’s much more cost-effective for both the designer and consumer to just get one of each: