<< The cables are the ones that comes with the monitors. They are 1 meter long each. Should I try switching them out for a shorter one? >>
Cables "shipped in the box" are notorious for being "lowest bidder" cables, and Readers Often find they are NOT adequate for the most extreme resolutions.
ThunderBolt cables running at top speeds (as these will be for these displays) are limited to 0.5 meters maximum length. Longer cables may be unreliable, and the first burst of transmission errors will throw the display offline.
So yes, buy at least one Thunderbolt cable (with a ThunderBolt logo on each end) and 0.5 meters or shorter.
<< I have tried HDMI as well, also with the cables that comes with the monitor, and I get the exact same issue. One works at a time. >>
As above, "shipped in the box" cables are often not good enough. The advantage of using the higher data rates for HDMI can ONLY be attained when ULTRA HDMI cables are used. These cables are completely different from all older HDMI cables (but are backward-compatible). The length is not specifically limited, but it makes sense to limit them to around 1 meter or less.
So yes, buy a certified ULTRA HDMI cable.