Closeup of the CM5 board with no flex cables, just a board with multiple flex connectors and a SMD 40 pin header. https://files.mastodon.social/media_attachments/files/111/364/560/520/553/562/original/4e3fbec43d1facf9.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.