Here’s an example of a state law. In the state of West Virginia, any party who received 1% or greater in the last gubernatorial election has automatic ballot access until after the next said election.
Obviously any Democrat or Republican will get greater than 1%. Sometimes a Libertarian, a Mountain Party, a Constitution Party, a Green Party, etc. has a good candidate and exceeds that threshold. Sometimes they do not.
When you have automatic ballot access, there is a slot reserved for that party’s nominee. In the spring of an election year, each party nominates via a primary election, a nominee for each office. The winner of that primary election appears under the qualifying party’s banner in the general election. Under the Presidential Election, Barack Obama and Mitt Romney will appear under the Democratic and Republican parties banner, respectively, because those parties are automatic qualifiers.
If you are a member of a non-qualifying party, then you get into a complicated system where you must gather enough signatures to have your name placed on the ballot. It’s expensive and time-consuming. There are arguments both for and against such a system, but it does keep from having thousands of crackpots on the ballot.