States control the process of deciding the boundaries for election districts. The political parties in power at the state level are able to construct the size and shape of these districts to ensure more of their candidates will be elected than the opposition party.
A possible solution to this is to select non-partisan citizens to construct these districts. In the 2018 elections, Michigan voters approved a new system for drawing the lines.
See also Changing the Math on Gerrymandering