The back of the CM5, showing the high-density 100-pin connectors that the CM4 uses. Also the 3d-printed standoffs are visible to the sides. https://files.mastodon.social/media_attachments/files/111/364/561/252/406/357/original/135b19159f29f1d4.jpg
How? Lots and lots of flex cables and adapters! PCIe, DSI, and CSI connect directly to the RPi 5, for HDMI, microSD, USB C, and USB A, there are adapters.