Red Dead Redemption 2 on PC Flash to Desktop Bug
This problem is likely because some app is stealing focus from the game.
In some cases, this can be solved by using Fullscreen mode or Borderless Fullscreen (also known as Borderless Windowed, Windowed Fullscreen, or similar). Unfortunately, it seems neither worked for you.
I used to have a similar issue with a different game (Metro Exodus). The game would automatically minimize whenever it lost focus.
To find out why my game kept losing focus, I wrote an app to keep track of any app that receives focus, then I let it run while playing the game until it minimized. The culprit turned out to be an RGB LED control software (Gigabyte RGB Fusion), which would regularly steal focus for no obvious reason.
You can find the app on GitHub. Scroll down for the README. It contains a download link for the app, as well as the .NET Core Desktop Runtime, which is needed to run the app. Windows will try to stop the app from running when you launch it the first time after downloading. This is normal, as it's an unsigned app. Simply click on "More info", then "Run anyway".
Uninstalling whatever software is responsible for stealing focus should fix your issue. If you can't or don't want to remove it, you could also turn it off while playing Red Dead Redemption 2, as well as any other game where the focus stealing leads to annoying behavior.