Two forces are at work in any election: The will of tens of millions of voters in the actual democratic showdown, and the influence of far smaller groups of political-party members.

As we're learning this year, those two forces often work against each other. More party "democracy" often produces candidates who are beholden to party insiders rather than the larger electorate.

Three parties – the Democrats and Republicans in the United States, and Labour in Britain – experienced the same phenomenon in the past year: a sudden surge in party membership or affiliation, driven by newer, younger, angrier voters excited by a potential new candidate.

Story continues below advertisement

This should have been a welcome development. But the candidates who attracted the new members, while exciting, were at odds with the parties' interests in general elections – that is, the party's core need to get into office, while remaining coherent and united as a party, to deliver policies that reflect their party's core values.

The three new candidates had a number of things in common. They all came either from outside the party, or (in the case of Labour Leader Jeremy Corbyn) from a faction of a party that had been suppressed or kept out of the spotlight for decades. All three identified as uncorrupted and free from donor-linked baggage. All three built their appeal on a form of politics highly focused on trade and military isolationism and championing of national interests. And all three employed a highly macho, old-fashioned approach to politics that seemed to threaten their parties' attempts to broaden their appeal to women, ethnic minorities and new communities.

The Democrats dealt with this challenge most effectively, in large part because Bernie Sanders, despite his "revolution" rhetoric and anti-establishment bona fides, was not in substance very different in ideology and outlook from the Barack Obama-Hillary Clinton coalition that forms the party's current centre-left mainstream. Mr. Sanders's views were largely welcome within the party (the isolationist tilt notwithstanding) – it was just that his supporters, more heavily skewed to white and male voters, didn't seem to be a large or diverse enough coalition to win.

As internal Democratic Party e-mails leaked to the public by mysterious (likely Russian) sources have shown this week, the Democratic administration worked hard to keep the spotlight on Ms. Clinton long before primary voters had officially chosen her. Then the party brokered a deal in which, in exchange for delivering his supporters, the party incorporated Mr. Sanders's better ideas (notably on climate-change policy) into the official party platform. In other words, the Democrats sacrificed some of the pseudo-democracy of primaries to enhance the actual democracy of the general election – and, for the most part, this week seemed to have succeeded.

The Republicans did the opposite. Until it was far too late, they acted as if "democracy" within their party were more important than an actual democratic outcome on Nov. 8 and a probability of realizing conservative policies thereafter. Only late in the spring did they fully realize they had a winning candidate who was fundamentally antithetical to those goals. Their last-ditch attempts to change the rules and override the primary-vote results failed.

The result of having relied on party "democracy" instead of real democracy is likely to badly damage their party, their country or both.

The Labour Party stands in the middle. Mr. Corbyn became its leader last year as a result of rule changes that allowed him to sell tens of thousands of £3 party-membership cards to supporters, overriding the resistance of the established party and its MPs. There was some hope he would renew the party – but then came the Brexit vote, which he ignored and neglected to a degree that even his close colleagues called "sabotage."

Story continues below advertisement

After crashing his country, he lost the faith of more than three-quarters of his MPs, who voted to oust him. But another party rule change prevented them from doing so: The faux-democracy of those £3 cards trumped the real democracy of tens of millions of voters and their MPs (only 2 per cent of Britons are political-party members), and he will likely hang on as leader this way for some time.

So 2016 has taught us that making political parties internally more "democratic" often makes actual democracy less democratic. It has been a hard lesson to learn.