There is a two part explanation. First parties are coalitions, and the segregationists might or might not have been the same people pushing the social programs. Secondly the parties in the US were much less aligned on ideological grounds at that time than they are now. Today the Republican Party is almost entirely conservative and the Democratic Party liberal, but back then the parties were much more mixed.