The 12th Amendment to the U.S. Constitution provides for the separate assignment of electors to the candidates for both the president and the vice president, as Wikipedia describes. According to the National Archives, this amendment, which was ratified in 1804, was passed in response to the contested election of 1800.
The 12th Amendment was passed to overturn Article II, Section 1, Clause 3 of the Constitution, which had previously defined the process for selecting the president and vice president. Under the old rule, each elector was permitted to vote for two candidates, provided that they did not both inhabit the same state as the elector. The old system almost immediately developed difficulties.
According to Wikipedia, the election of 1796 saw John Adams win the majority of votes from electors, but the Federalist electors had split their votes for vice president, resulting in the election of Thomas Jefferson. This process became more problematic in 1800, when it was discovered that if each elector voted with his party, the result would be an all-around tie that would move to Congress to be broken. Under the 12th Amendment, electors were permitted to cast a single vote for president and a single vote for vice president instead of voting twice in the same race.