The Democratic Party at one time was the more libertarian of the two major parties. But then the meaning of "liberal" changed in American politics to not be the same as libertarian . The Democratic Party remained liberal, but Reagan remained libertarian. At the same time, because big business sought more to protect itself from government than to make use of government as it had pre-Roosevelt, the Republican Party became more accommodating of libertarianism. So, without changing Reagan, for him to remain a Democrat requires both that the Democratic Party not abandon libertarianism and the Republican Party not try to bring libertarians into its tent. I once began, but did not finish an alt hist timeline in which the Democrats changed as per OTL but the Republicans did not and Reagan became one of the founding stars of the Libertarian Party.
Reagan was still a Democrat in 1948.