Flexible cables and flex PCBs are wonderful ... and that’s why you can buy them pre-made in tons of different pin pitches and sizes. If you need one board to interface with another board ...