The more burning question I have is, What business does a "private" national party have controlling the candidates visible to within-State electors on ballots or gaining de facto government sponsorship through nominations?
Regarding presidential elections, the Constitution says,
Each State shall appoint, in such Manner as the Legislature thereof may direct, a Number of Electors
(Article II, Section 1, Clause 2)
No power is vested in parties by the governments per the Constitution (nor are popular elections or bound delegates at the national level allowed, but that is another matter). No political clout is allowable for parties other than the natural and organic assembly of the people to organize their minds to campaign and raise public awareness of certain candidates. Legally, they cannot be recognized as being invested with any power whatsoever beyond the rights of their individual subscribers.
But how does the reverse relationship work?
To answer your question,
On what legal basis do state governments regulate party primaries?
Under false doctrines of modernity that the "electoral college" somehow permits national parties to hamstring State legislatures into a narrow list of options (and to gain State sponsorship through published ballots and practically monopolizing official government communication channels and resources), it is merely assumed that the parties are a legitimate and practically public political entity with authority vested in them by each State, deserving of sponsorship and preferential treatment. Under this incestuous presumption, it then becomes possible for governments to regulate the parties as though they were subsidiaries falling within their oversight of Public Affairs, rather than being private organizations run only by the rules of their constituents.
You are right that concerns akin to protectionism of businesses apply. Most of this control stems from unwritten rules and the de facto usurpation of the American polity by a two-party system, but no matter what legality is claimed, it cannot be with the support of the Constitution, since limitations of public assembly and representation as well as deviations from the Constitutionally appointed mechanism for choosing electors and for counting their votes are expressly unconstitutional. The Constitution as originally written prohibited any kind of public power from being vested in parties, and therefore specifically precluded the formation of effective controlling national parties or their regulation or empowerment as though they were official arms of the government itself, and yet here we are.
The Twelfth Amendment partially abolished Constitutional protections against party tyranny by obliterating the runner-up condition of the original two-seat race. As it functioned under the original Constitution, presidential elections would have most commonly functioned in a multi-party environment by having the president elected from one major party and the vice president from a different party, preventing the highly contentious power swings we are accustomed to today, and eliminating the monopoly of the two major parties. (This would incidentally also completely change the dynamic of the news cycle, since it would not predictably and obsessively focus only on two major parties and their contentions, and the powers that be weren't having that.)
Today, we do not even follow the amended Constitution--but who can be made to care these days what our written Constitution actually says?
In short there is no Constitutionally allowable basis for the promotion or regulation of--or investiture of government power in--political parties. Political parties ought to be limited to and exclusively governed by private organization, per the Constitution itself, which grants them no power out of the prerogatives and public oversight granted exclusively to public servants and officers of a bona fide, Constitutional government.
Once parties are no longer granted a privileged or controlling status over State legislatures in their oversight of elections, State legislatures will correspondingly have no grounds for intervention in the private rules of said parties (unless someone's Constitutional rights are infringed thereby), and the controlling and divisive national two-party system will have been abolished, the only alternative being a genuine grassroots system for organization of numerous local political parties, each having considerable and real clout and self-governance, rather than being under the regulatory thumb of State or national interests.
Of course this will require states to adopt resolutions sustaining the United States Constitution and abolishing the special privileges granted to parties, and to return to the actual electoral methods enjoined by the Constitution, rather than the faux partisan-controlled electoral college of today.