The racist Alabama Democratic party is the answer. Alabama was a one-party Democratic state that excluded blacks from meaningful participation. How? Only white people could belong to the Democratic party. They would a hold a closed primary, conducted and paid for by the State, among its members only, and select a candidate. This person would then be the only white candidate on the ballot and would win in the general election, where the few blacks who had managed to register, could vote, but would be shut out.
Part of the Civil Rights/Voting Rights acts and de-segregation court cases, required that primaries (and actually party membership) be open to all. Technically, if you vote in an a party primary, you are declaring that day you want to be a member of that party, and help select its candidates. I remember the voting documents used to actually say that.
In Alabama, you do not declare a party membership in advance of an election. In a “closed” system, you would have to declare a certain party a certain number of days in advance of the election, and there would be a registration book of just those declarers on election day. Its all historic accident, not design anymore. The USDOJ could stop to sue such a change under Voting Rights Act, but with States no longer needing DOJ pre-approval for election changes anymore, it would likely happen.