Well, it's not supposed to be, at least in a perfect world (which obviously we don't live in). In theory, voters cast a ballot for the best candidate for the job. Reality is depressing.The US Congress is the perfect example of the antithesis of meritocracy...
A lot of people don't know this, but until 1913, US senators were elected by each state's legislators, not by popular votes. The 17th Amendment to the Constitution (in 1913) changed elections for senators to "direct election". In the Senate's own words:
U.S. Senate: Landmark Legislation: The Seventeenth Amendment to the Constitution
Landmark Legislation: Seventeenth Amendment
I'm not sure which method of choosing senators is better...
