How does the game decide when to be on attack and defense in QP?

I have played over 10 games today and all were defenses. Seriously I am sick of hearing “prepare your defenses”.
How is this game deciding when to be on attack and when to be on defense? Is it completely random? Why can’t Blizzard do something as simple as this right?

Have you tried not leaving when the game ends? The it normally go to attack.
But I agree that if you leave, moste often start on defence.

When joining a lobby for the first time, it’s mainly random which side you’re in. After the first game, teams switch sides and play on the same map. After that, a new map will be selected and so on.

If you stay in the lobby (don’t leave the game), you will play both defense and attack (and you get extra xp for playing consecutive matches)

AFAIK it’s random unless you stay for consecutive games where it tries to switch you up. Sometimes you’ll be put on the same side as the previous round if there’s a 5+1v5+1 premade battle going on and the only way the system can balance the teams to have 40/60 winratio is by switching the solo players between teams.

If anyone finds anything concrete straight from Bliz about this quote me pls