There's the electoral college which was set up deliberately as an antidemocratic measure by the founding fathers. More so than it is now. But we haven't gotten to that stage of the season yet.
Right now we're in the primaries, which is an entirely ad-hoc system made up on a party by party, state by state basis. Each state decides when the primaries happen and what form of election they will be. Each party decides how those results will be counted in their own convention. There's little to no federal regulation regarding the primary process. The end result is a year long spectacle.
Of course this season we're being denied the spectacle for a shitty rerun.
There's an incredibly stupid Iowa state law saying their caucus has to be at least 8 days before any primary.
There's a similarly stupid New Hampshire state law saying their primary has to be at least 7 days before any other primary.
Those laws don't actually mean anything, and doubly so because there's actually no law saying primaries have to take place at all.
The Democratic and Republican parties put out their own schedules of what states get to go first, and if any state breaks the rules the results don't count.
This year the Democratic party said South Carolina is supposed to be the first primary, but New Hampshire set theirs first anyway, and so Biden wasn't on the ballot and the New Hampshire results don't count.