At a federal level, the constitution itself does this structurally by requiring an absolute majority in the electoral college for a president to win; and that makes a president from an emergent third party very difficult. That party would have to already be competitive in a majority of states, but that's also difficult if that party can't ever promote someone to the presidency and use the national bully pulpit to the party's advantage. And whenever a 3rd party person appears in Congress, the existing two parties require them to caucus with either Democrats or Republicans, in order to get committee assignments and you know, do anything other than vote on stuff. You're not a legislator if you aren't on any committees.
At a state level, election laws do things like guaranteeing the two parties a position on various ballots: city, county, state, federal. But then put in all kinds of onerous requirements for other parties just to get on the ballot. While Democrats and Republicans are using resources for other things, upstart parties have to spend money and volunteers just to get signatures in order to get on ballots and appear in debates. Primaries are tax payer funded, free publicity for established parties. Numerous laws exist for small things like elections commissions only having either Democrats or Republicans seated - i.e. if you're a third party, you can't even run for a state or county elections commission, it's prohibited. These sorts of things are very state by state or even by county.
But as I indicated in my original post, it's how U.S. elections favor the lesser of two evils strategy, else you get punished when voting for who you really want. Minor parties seldom get pluralities, and they suck away votes from an ideologically similar major party candidate which can cause them to lose, and then its the ideological opponent who wins as a result. Duverger's Law is what it's called.