While I am a leftist (not a liberal nor a tankie retard) imma talk from history (I'm autistic about this)
in a spark notes version basically the party switch can be in thanks due to the northern Democrats who were more pro civil rights unlike the southern Democrats who were not, southern Democrats who felt like the northern Democrats who were becoming the majority were too much like the Republicans
though we can also attribute this to FDR who's new deal offered progressivism that was scene as something new to the Republicans who were more of an ideology called "liberal conservatism" which is socially conservative but economically more classically liberal