Answer:
Presidential candidates are officially selected by their political parties in national conventions that meet every four years. This convention is consisted of delegates from each state that are pledged to vote for the state's desired candidate.
Nowadays, so many states hold binding primary elections or caucuses that it is possible to have the nomination virtually secured before the national convention, and that is what has happened recently. The primaries are held at different times and the losers of the early primaries tend to drop out one by one , eventually leaving just one still standing.
If the primaries did not produce a clear winner, the convention delegates at the national convention would vote to choose the nominee.
Occasionally a protest candidate , with some help from friends, will form his own party. In other words , the party is formed to support one particular person as nominee.