to switch sides, to turn one's coat
Só porque o time dele estava perdendo, ele virou a casaca!
Just because his team was losing, he switched sides!
Once an English expression for joining a political party out of opportunism, it became common in 20th-century Brazilian political coverage during periods of party-switching ('trocar de partido' / 'dar uma virada'). The Portuguese 'virar a casaca' (literally 'turn the coat') tracks the English 'turncoat.'
Source: Etymonline — turncoat.
Falando's Idiom Trainer teaches you to recognize idiom meanings and create sentences using them, so you can speak like a Brazilian.