process = subprocess.Popen(command_array, ...)
When you run that line, it opens a new python.exe process that creates another top-level window. This new process temporarily gets primary focus.
To fix this you should manually reassign the topmost property after the new window is created to regain priority.