1) Primaries: states run party primaries in many ways, some of which seem to lead to more moderate candidates being selected from each party. But most states run standard primaries limited to registered members of each party. Because the extremists from each party are more likely to vote than the moderates, this means that extremists are more likely to be selected to run in the general election.
[we will soon have an academic white paper here, with links to research on primaries]