Probably an application or service is starting up silently in the background and taking the focus. I'd look at Task Scheduler first, and see if something's set to run on a schedule; other than normal Microsoft maintenance tasks.
If you don't see anything obvious, the next step would be to perform a clean boot and see if the problem ceases. If it does; then you start re-enabling one item at a time, followed by a reboot, until the problem re-appears.
The last item you enabled (program, service, or driver) will be the cause of your windows losing focus, and will need to be either updated, disabled, or uninstalled. It's a PITA, but it's the only way to positively identify the culprit that I know of.
EDIT: There's a third possibility you may want to eliminate before having to go through the PITA clean boot procedure; MALWARE! Run a thorough scan with Malwarebytes and/or ComboFix.
.