Article 21 of the German Basic Law states
Political parties shall participate in the formation of the political will of the people. [...] Details shall be regulated by federal laws.
...and they are, so much that there is the word "Parteiendemokratie" to describe the German political system.
In contrast, political parties in the U.S. were established well after the constitution, and seem to have a different role. This German-language blog "USA explained" even goes so far to claim "There are no political parties [in the US]. It just seems that way. It's an illusion" (which, itself, is a movie allusion). Yet, as mentioned here, political parties in some U.S. states do not have to organize the election of their own candidates for a general election but have that done by state election officials, for example.
So what is the legal role for political parties and where is it defined?