This sounds similar to my issue with W11, which was not present in W10.
I use a laptop with a docking station as my daily driver (Dell). Previously on W10, when I undock, all of my open Windows will be moved to the single built-in laptop screen. With W11, when I undock, the Windows stay on the now non-existent screens, and I have to mess around with the taskbar previews to coax the Windows back onto my only existing display.
This functionality has existed since at least Windows 2000 and XP; not sure why it's an issue again. I keep hoping for a Microsoft or Dell update to fix it, but none so far. Bug reports and feature requests do not seem to get me anywhere.
I have seen this behavior on a few different model laptops with W11. I have run W10 on this laptop before without any issues with Window placement after undocking, so it is specifically W11 exhibiting this behavior. I would have thought MS would have made the thing the OS is named for work, but I guess that is too much to ask for.
Also saw a comment about Power Toys to tweak power settings. Power Toys also has a Window management tool that you can use to snap windows to predefined locations on the screen; very useful for a multi-monitor setup or if you have a monitor with a ton of real estate to keep things in a consistent location—definitely, a time saver if you are manually placing and sizing Windows regularly.