There was never a switch. They never swapped values.
In the 20th Century, the Democratic Party began to progress.
The Republican Party chose not to.
So there was no switch, the Democratic Party just decided to allowed change.
Southern* Democrats filibustered the Civil Rights Act for 75 days.
Northern Democrats did not.
And when Democrats passed the Civil Rights Act and went on to desegregate the South, White Southerners started tearing up their party registration cards and joined up with the Republican Party which didn't have as much a problem with segregation.