It sounds like something running on your computer is stealing your focus (the "focused" window is the one in the foreground, that accepts your input). If so, it could be a service or a program running in the background, that doesn't show any window, but still "Steals" your focus by putting other programs in the "background" (unfocused) when it performs some background operation.
I'd try running Malwarebytes to scan for malware/grayware. Malwarebytes is free to use for 14 days.
I'd also go through your list of installed apps (Settings -> Apps) and uninstall anything you didn't install yourself, that you're sure you don't need.