Fun bit of trivia, every Nintendo console that has had backwards compatibility did it at the hardware level by literally including the previous console inside.
GBA contains the GBC's Sharp SM83 CPU, and it's only there to run GB(C) games. GBA software never touches it.
DS contains the GBA's ARM7, which DS games can also use as a coprocessor. The SM83 is omitted though, which is why it will not run GB(C) games anymore. To keep you from trying, the cartridges are shaped slightly differently and will not fit snugly in the DS, but that's just plastic - the cartridge reader is otherwise the same.
3DS contains
both the DS's ARM9 and the GBA's ARM7, the latter is necessary since DS games use it. They just didn't include a cartridge slot for GBA games, but the Ambassador "VC" releases are able to run on that hardware. This is why the Ambassador games cannot suspend to the home menu or even use sleep mode, they boot into a compatibility mode that disables all 3DS hardware. With homebrew it's possible to inject other ROMs as well.
Wii is a little more complicated. Rather than including Gamecube hardware separately, its CPU and GPU are based on the Gamecube's architecture, just at higher clockspeeds (I'm simplifying this a bit, there's more to it). By downclocking, they become perfectly compatible with Gamecube software.
Wii U is even more complicated. I'm not even going to try to explain this one,
but you can read Rodrigo Copetti's documentation if you're interested. The disc reader won't accept 8cm Gamecube discs, nor does it have controller ports or memory card slots, but the hardware is secretly still compatible and can be hacked via homebrew.
Also, did you know that the SNES CPU boots into a 6502-compatible "NES mode" before SNES software instructs it to switch to native mode? I haven't been able to find much technical documentation on this, but evidently it doesn't actually run NES software, but was likely supposed to. Backwards compatibility was initially advertised when the console was first announced, only to be silently dropped at some point in development.
It is a near certainty that the Switch 2 will build on the Switch's architecture. The ARM4 and Tegra X1 are generic enough that they can easily be built upon while maintaining compatibility (I am, again, simplifying a lot here), there's nothing they would need to break away for. Switch had to break the Wii U in order to transition to a hybrid, but they don't need to do that a second time, and if they don't need to then they won't.
And with how much slower the transition between console generations is these days - look at the pace of PS5 and XBS adoption, as well as how many games still get cross-gen releases - backwards compatibility is absolutely essential to bridge the gap. In fact, the big three may all be permanently locked in to the architectures they're using now, if they ever try to reset and launch a new console without backwards compatibility they would die as a result.