Destop switch to other monitor

I have imac 27" with an external acer G276hl monitor.
I setup 11 desktops on the Acer and assigned multiple apps to each desktop.
Now all off the desktops have moved to the IMAC.
Number 1 why would this happen and numer 2 is there a way to revert to the original configuration without manually doing it.

In short I don’t know why. Some users have seen OSX desktops migrate when unplugging then re-plugging a monitor in. In theory they should move back to be on the same screen they were originally on when the display is plugged back in. But for unknown reasons OSX does not always do this.

I did make a tool to mitigate this a little - - you record a particular desktop setup and then can restore it at a later time (so it automatically migrates the desktops to the right screen).

Also, if you enter Mission Control, I believe you can drag desktops from one screen to another.

Thanks, Stephen
Hopefully it will not happen again, but the tool will be useful, just in case.