Democrats do it too, but to a lesser extent. Gerrymandering is redrawing district lines in a way that significantly favors one party. To my knowledge, partisan gerrymandering is not against the law, but racial gerrymandering is. For example you can redraw your district to heavily favor your party, but if you redraw it on the basis of race, for example drawing the lines based on where African-Americans live, that would be illegal and there have been several court rulings against the GOP for doing so.
In most cases, the state legislature does the redistricting; in other words the ruling party redraws the district lines. In a few states this is done by an independent body to prevent gerrymandering.
Take a look at this example. The first image is the total representation of blue and red in the area. The second image illustrates a correct and balanced way of redrawing district lines, and the other 2 images illustrate how gerrymandering gives one side a major advantage. The total representation of the area was initially 60% blue and 40% red. In the second image, a perfect representation would therefore draw the lines between the red and blue areas so they have equal representation. 3 blue districts and 2 red districts.
Now let's look at the second example. Compact but unfair.
This is what simple gerrymandering looks like. As you can see, there are no longer any red districts. The lines have been drawn so blue holds a majority in the entire area as there are now 0 red districts. All 5 districts are blue now. This means this area is now completely in favor of the blues.
The final example is a more accurate representation of gerrymandering in real life as parties go to great lengths to redraw district lines in their favor. It's a lot more complex than this image of course but in severe cases you will see some crazy district lines that really don't make any sense, just to favor their party.
In this case, the lines were redrawn both very complicated and very unfairly as it gives the minority (remember the total representation of 60% blue and 40% red) an advantage over the majority. There are now 3 red districts and only 2 blue districts. This means red now has a large advantage despite the area's total representation of 40% red.
I could be wrong on certain points (correct me if I am) as I am not a US citizen but I hope I've provided you with the answer to your question.