Disable this option.
[Debug Configurations > Common]

With that option disabled, 'Progress' window is in foreground during debug session launch process.

This is related to Cube's behaviour where the 'Run/Resume' button becomes enabled even though the flashing of the board has not finished.

https://community.st.com/t5/stm32cubeide-mcus/jumping-to-random-file-after-pressing-run-button/td-p/246693/highlight/true/page/2