You ban gerrymandering by passing laws to create strict rules about how districts are made. It's tricky but there's some science.
Ranked choice is easier to implement at the state level. At the national level we need a Constitutional amendment. However, there is good news, we might get enough states onboard with the National Popular Vote Interstate Compact to kill the Electoral College.