When a window is not assigned to any desktop (Dock icon -> Options -> Assign To: None), when switching desktops using the trackpad, it may sometimes move the window to the newly selected desktop.
I have two Finder windows that I want to keep each one on a specific desktop, but I can't seem to prevent them from following me when I switch to another desktop while they are focused.
I'm not sure wether this issue is only applicable to the Finder or not.
This bug doesn't occur consistently, and I haven't been able to reproduce it reliably. However, I've identified the conditions and reason for the window movement as described above.
Benjamin also experienced this issue on Ventura and posted about it here: Prevent finder window from switching between spaces when using Mission Control However, his post was closed as a duplicate of other unrelated issues.