It's not quite "signing up", at least not in all states. Not all states have formal voting registration, but since the parties still want to have voter databases in those states, they just infer your likely party preference without you explicitly signing up. In Texas, for example, primaries are open, and you can vote in a different one in each election if you want, but not more than one in the same election. What political parties typically put in their voter databases are people who've voted in their primary in N consecutive elections, typically N=2 or 3. So e.g. if you vote in two consecutive Democratic primaries, you're likely to start getting a lot of D spam (and likewise for the Republican primaries).
But in any case the legal answer is simpler: political calls are explicitly exempt from the various no-call lists and telemarketing laws (in the U.S.), so they don't really need any justification for why they put you on the list.
But isn't the point of this to help the campaigns identify and avoid people like yourself who would not welcome their advances.