How campaigns polarize the electorate