Windows has had a “prevent apps from stealing focus” option for at least a decade. It was one of the things that I still dislike the most about macOS, and Apple can absolutely address this.
How does that even work?
When you launch an application or open a dialog, you expect the new window to "steal" focus. When you close a dialog, you expect focus to go back to the main window. If it didn't, it would impair usability.
So how would an OS decide when "stealing focus" is allowed and when it is not?
Like, I'm frustrated with it too. I hate when an app pops up a dialog while I'm typing and my next keystroke dismisses it and I have no idea what I've done. But at the same time, I'd hate to have to manually switch focus to a pop-up dialog every single time before dismissing it with Enter or Escape too -- that would be way too annoying in the other direction.
Where's that hiding? Discord is horrifically guilty of this across every OS, so I'd love a way to quash that on at least one.
Adobe programs were the worst offenders for this in my experience.
Windows has no such option, and regularly steals focus, particularly Visual Studio/Debug tools/applications loading. It had an option for a short period with the original TweakUI, but Microsoft removed support for it even in the registry.
No OS should steal focus, Windows absolutely is guilty of it.