I had this issue for over a year with 2 macbooks. Might have found a solution though. I believe that the issue, at least for me, comes from using 2-factor authentication on my google account.
So, the issue that mail opens by itself was for me only happening when the application was running while not having the main mail window open anywhere. If the application was not open (had been quit) or if the main window was open in the background somewhere, it did not open by itself. It only opened when I had my gmail account active, so deactivating it also stopped it from not opening by itself, but that is not really a solution. But I think I have found something that works.
I, just a few days ago, deactivated my gmail account in the mail application and activated it again, but not using the easy google "preset". Instead, under "Preferences..." in mail and then in the "Accounts" tab, I clicked the plus symbol in the lower left corner to add a new account and selected "Other Mail Account...". Then entered my google account name and gmail address, went to my google account in a web browser ("account.google.com") and under "Security" generated a new "App password" and used that to login to my gmail account in the mail application.
The mail window has not opened by itself yet, so it has so far been a success for me. Hope this helps someone else with the same or similar issue :)