Bump.
Same issue here. After it goes into sleep mode (or even screen saver mode) it returns and the open windows on my 32" Samsung monitor are now in the main iMac 27" 5K screen. The smaller 24" Samsung window seems to remember the windows in it and are not impacted by the "bug". Both monitors are driven by Thunderbolt ports to a DisplayPort on the monitors.
Possibly related or not.....when I upgraded to Monterey, my Time Machine got screwy with a display issue as well (google search and others have the same issue). When I manually start TM, I can't see most of the screen as it appears there is a "fantom" window covering a large portion of the center screen. The only way I've found to get rid of that issue is to unplug all external monitors which forces it to the main display and it no longer has the "fantom" black window. Not sure if others that have this issue (disappearing windows in external monitor(s)) also have the Time Machine problem. Curious to see if they are related....
Not sure if Apple thinks this is a bug or just settings on the monitor. I've tried different cables, setting the refresh to 30 HZ, but nothing seems to work. Did try setting PRAM but works for a few times but returns back to issue. I have turn off sleeping which works for awhile until it doesn't. Clearly by the number of people responding, others have this problem as well. Most on laptops but I think that is due to people not hooking up external displays on iMacs. I use my rig for stock/option trading hence the 3 screens. My guess is if others hook up external screens, they may experience the issue with *some* monitors.
Jeff-
4.2 GHz Intel i7 2017
48 GB DDR4
Monterey 12.1
32" Samsung 3840x2160 DisplayPort 60Hz Model: LU32J590UQNXZA
24" Samsung 1920x1080 DisplayPort 60 Hz Model: LS24E45KDSG/GO