See title. I don't want to get political in this forum so please don't take the examples too seriously. This would be in a situation like how Christianity went from a persecuted regional sect to the main religion of the Roman Empire, or maybe a labor union that accumulates enough clout that it starts to oppress the company that contracts it? But even though this once-oppressed group is now in power, it may continue to have the mindset of and pursue goals in the manner of an outgroup.
"Tail wagging the dog" would be on the right path, but not correct because the tail remains a small and secondary part of the dog. In that metaphorical world I'd want something more like "Tail becoming the leash". "Cart before the horse" isn't quite right either; "cart driving the horse" would actually be pretty close, but that's not an existing phrase.
I'm hoping this is a phenomenon that has a technical name that I could research, but I'd settle for an idiom.
Edited after reading Erin-Kate Sousa's answer.