I think a lot of that was momentum: The South still had racist Democrats they could vote for in local elections, who had been their Representatives and Senators for a long time. A lot of them actually had a family connection, since their fathers had been in their office before them. They didn't suddenly embrace civil rights, either. 30 or 40 years later, they were either dead or retired.

Reagan was a fluke, like Trump. He won because of his media career and huge name recognition, not his political history. Both of them were actually Democrats before they turned Republican to run for office. Reagan was actually a union President!