> I'm assuming displays have detectable ids of some sort?
Yes, the EDID information uniquely identifies a screen. https://en.m.wikipedia.org/wiki/Extended_Display_Identificat...
> Why can't linux do this?
It does for me (fedora, gnome, wayland). Other stacks are more work. I was put off using Sway as my desktop, because screen resolutions and layouts was manual.