Philipp Defner (also: Hacker News):
Since macOS 10.12 there’s a bug in Apple Mail that causes it to randomly become the frontmost application. If you are in full screen mode — like when you are giving a talk or watching a movie — it opens itself up in split view mode where it takes up half the screen while your other main window is being resized.
[…]
After some research it became clear that it’s related to Gmail and I’m not exactly the only one[…]
As a developer of a Mail plug-in, I’ve been hearing about this for years. People assume it must be caused by third-party software, but in fact it can occur with a clean macOS installation. I’m not sure that it’s limited to Gmail accounts. It may just affect more Gmail users because (a) there are a lot of Gmail users, and (b) Gmail’s IMAP implementation is particularly unreliable, often unavailable for short periods of time.
It seems to happen because of improper error handling. If you look closely at the app in the instant it opens, your affected account will have a “disconnected” symbol next to it in the sidebar. However, it goes away before an error can be shown.
My theory is: there is a momentary connection issue with these G Suite accounts, and Mail.app starts to show an error by focusing itself, but the error is resolved so quickly it doesn’t actually get to show the “connection problems” modal.
In my experience, if you always hide the Mail window (cmd-h) instead of closing it (cmd-w), it won’t ever pop back up. Takes a while to retrain the muscle memory though!
Update (2020-06-02): mkalina:
Not only with Gmail. Same happens with O365/Exchange, too.