How does MKV segment linking work?
It's not the container that 'knows' that, it is a player. And it is a good question how it managed to find the file in the different directory.

The only thing that the container does to help the player to identify the blocks is storing the Previous UID and Next UID for the files. It also stores the UID for the current file. So my guess would be that you have a player with some sort of 'library' capability, the player has scanned your drive and recorded the UIDs of the MKV files that it found, it then encounters the Next UID field in a file that it's playing and it will know where to look for the next one.