I've never understood why operating systems allow focus switching.
It's always been a pox on Windows, but macOS does this more and more these days. Just this morning, I plugged in a USB hard drive, then returned to my other work while it mounted. Suddenly, I'm typing a memo into Finder's password field to unlock the drive. Just. Stop. It.
If you need my attention, there is no shortage of methods to do that — Beep. Bounce the icon in the dock. Notifications messages. Your stupid program is not more important than whatever I'm doing at that moment in time.