The following applies to the Steam version of the game.
Before this patch (and still hold true, currently) the steps to reproduce are:
Select a PvP match, but don’t go into battle yet.
Press edit teams.
Exit edit teams. (It doesnt matter what you actually do on the edit teams screen.)
Back out once again instead of heading into battle.
Now, your defense team has not actually been switched yet on the server at this point. If you completely exit the game from where you stand after repeating just these steps, your defense team stays what it is supposed to be after reloading.
However, any of the following will save the defense team on the server:
Backing out of PvP completely
Visiting any other PvP tab
Fighting any other battle and doing either of these.
Basically, you have no legit way out of PvP without triggering the swap at this point.
Video showing the steps to make this happen:
You can tell when it happens, as you get the loading wheel briefly. Not the beachball, this one:
You can verify your team has not been switched yet by opening the chat and attempting to fight yourself.
All of these things are still repeatable and still occur in this version, except for fighting another battle saving your team to the server. Fighting another battle immediately after clicking edit teams has the same effect as clicking edit teams, backing out, and fighting any battle (on the same tab), which is the “new” form of the glitch as explained below.
What has changed in this update is that clicking edit teams anywhere in PvP now has your defense team get switched to the last team you looked at in the edit teams screen even if you enter a battle. However, once again, these changes don’t make it to the server. I’ve yet to produce a way to force the changes onto the server without triggering something either the original form of the glitch or manually switching my defense team. Changing tabs or exiting PvP will not initiate the server contact that saves the errant defense team, but it will stay that way on your defenders tab until you either trigger the glitch, edit teams from the defenders tab, or exit and restart the game. Once again, you can verify the team has not actually switched on the servers by attempting to fight yourself through chat or the leaderboard.
As shown here, after triggering the glitch by clicking edit teams and then completing a battle, your team has not actually switched:
I strongly believe this is because the client has no reason to tell the server that it has switched teams and therefore will not update your actual team and the server is not contacted to get the “correct” team, either.
However, the crux of the issue is that the edit teams button in the PvP preview screen functions like the one in the defenders tab with some added glitchiness where it occasionally doesn’t save the team properly. Instead of focusing on the “new” iteration of the glitch, which is basically the old one but with less client/ server contact, the defense team switching functionality probably should be severed from the edit teams button entirely. Hopefully this can be done without a major client update, or we could be waiting a while for a proper fix.
Edit, more to add:
If you trigger v1 of the glitch, going to the defenders tab does not actually change your team on the server, but you can see that it is swapped on the client. Going to any other tab, including the tab you are on (eg., Ranked/Casual) will trigger the swap. This is, again, because the edit teams button in PvP has the same extra functionality as the one in the defenders tab.
Triggering v2 of the glitch will occasionally fail to dispose some of the overlay elements from the PvP preview screen.
You can trigger the glitch by using the edit teams button in any sub window of PvP, including fighting someone or yourself via the leaderboard or in chat.