The only way you will know if it’s the metformin is to stop it for a few days (obviously you should speak with your health provider).
I have been on metformin from 2014, T2 and I can honestly say it’s caused constant stomach issues for me but I stuck with it until end of June this year When I had enough. I stopped it myself, bought a Blood glucose monitor, went low carb to control the numbers.
My running to the loo issues stopped more or less straightaway and my blood glucose numbers were marginally different without the metformin. In my opinion not worth the constant dashing to the loo and the anxiety surrounding this.
Daily testing before meals and 2 hours after is working for me .
Hope your stomach settles soon.