While I have no reason to doubt your experience, and I am sympathetic to your results, I think it merits further testing. While it could be a simple coincidence, the fact that it happens twice points to the possibility of relational causation.
From my personal experience, I have never seen GA being detrimental to rankings nor AdSense earnings and I have done numerous tests. If I were to venture a guess it would be that something in the way that you implemented the Google Analytics code was detrimental to your website’s performance.
Perhaps you were just a hair above the page load speed threshold that causes a lowering of rankings and the extra time added by the GA code pushed your page over the limit. Or perhaps the location of your snippet within your code was less than optimal? It doesn’t take much of a page load speed issue to seriously harm ad revenue.
It seems to me that there are too many unanswered questions to draw any reasonable conclusion beyond the simple fact that “something was wrong”. To jump to the conclusion that it was something Google was doing is too much of a leap and not supported by my own experiences.
Why not have an expert, someone you trust, take a close look at the implementation methods you used to see if they can spot the issue? It could be that you can “have your cake, and it eat it too” if you dig into this a bit more.