Unfortunately gerrymandering is a flaw in the democratic process. At least in the US, the Voting Rights Act makes it so political parties cannot redraw districts to decrease the political influence of racial or ethnic groups. It says nothing about other political parties, so whichever party is in power when voting lines need to be redrawn will inevitably try to redraw the lines in their favor. Until that sort of gerrymandering is outlawed, it will continue to happen. The party in power isn’t going to make it fair for their competition out of the kindness of their heart.
“Sorry Timmy, I’ll buy you ice cream on the way home if you don’t tell mom I was rooting against you”