It used to block focus stealing aggressively unless a program had foreground permission or was given it (AllowSetForegroundWindow), but the mechanism seems broken in current versions of Windows.
But the last time I tried to test code using this to properly hand off foreground permission from one process to another, I had a hard time testing it because I couldn't get it to fail. When this mechanism was first introduced in Windows 98 and 2000, it was pretty aggressive -- if you were past the input timeout and foreground permission hadn't been forwarded or already shared, the target application would fail to come to the front and its taskbar button would light up instead. I haven't seen this happen in a long time on current Windows, programs steal focus all the time.
Haven't used windows in a decade, but there is (was?) a registry setting that would disable focus stealing prevention. Some egregious tools "helpfully" changed that setting for you when you installed them, because they couldn't get focus management to work properly. Maybe it's that?
I'm pretty sure something weird is going on in your case because I recently had to fight a case of this that had seemingly gotten more aggressive in Windows 11, not less. The focus stealing prevention has always been there and is still there as far as I've observed.