Gerrymandering does nothing to get more actual votes for a party. Instead, it tries to create legislative districts in such a way that the votes that the party does get result in the greatest possible number of seats in the legislature.
Let us say, for example, that there are two adjacent legislative districts with populations of the same size. In one, Party A has 70 percent of the vote and Party B has 30. In the other, Party A has 40 percent of the vote and Party B has 60. Each party will typically win one district. But now let us say that Party A gets to draw the lines. They have a clear incentive to gerrymander. This is because the two-district area as a whole is 55 percent for Party A and 45 percent for Party B. If Party A can draw the lines so as to divide its voters evenly between the two districts, it will win both of them every time. This is why gerrymandering is useful. It can optimize the distribution of votes so that the same number of votes for a party can lead to a larger number of elected officials for that party.
The term "gerrymander" was named for Governor Gerry of Massachusetts who in 1812 reshaped electoral districts in Boston to benefit his party. People claimed that the new electoral map was shaped like a salamander and thus the scheme was called a "Gerry-mander" a portmanteau word combining "Gerry" and "salamander".
Gerrymandering historically has been done along both racial and partisan lines in the United States. Imagine that you have 4 districts, each containing 50 white and 50 black people (total 200 black and 200 white voters). In this case, white and black voters will have equal power in electing representatives from all 4 districts. Imagine though, you redraw the districts so that District A contains 100 black people and Districts B, C, and D each approximately 33 black and 66 white people. In this case, essentially you have given black people a huge majority in one district and white people control of 3 districts. The same can be done with parties. In the 21st century, the Republican party has been notorious for redrawing electoral boundaries to its own advantage in this way.
The Supreme Court in 1986 ruled that gerrymandering violated the Equal Protection Clause of the Constitution but could not articulate clear remedies. Many groups advocate that electoral districts should be shaped by nonpartisan technocrats rather than politicians to create a fairer and more democratic society, but such idealism is unlikely to convince Republican legislatures to relinquish the power they have gained through gerrymandering in the past decade.