Variable gauge trains help overcome this problem:
https://en.m.wikipedia.org/wiki/Variable_gauge
I once took a night train from Barcelona to Paris that changed gauge at the border. It slowed to a walking pace and travelled through a shed like structure that housed the equipment. There was some mild clunking and clanging from underneath as we slid over the mechanism. Quite impressive.