I can only speak to formation of governments in systems based on the British system, sometimes referred to as the Westminster parliamentary system. Dunno how it works in other parliamentary systems, like Germany, France or Israel.
The starting point to forming a government is having a working majority in the most representative chamber of Parliament. In bicameral parliaments in the UK and Canada, that means a working majority in the House of Commons. In Australia, it’s the House of Representatives. In unicameral parliaments like New Zealand and the Canadian provinces, it’s a working majority in the Assembly (or whatever name is used in that jurisdiction).
What’s a working majority? If one party wins a clear majority of seats (not popular vote, mentioned in the OP), then that party has a working majority. The leader of that party will be the Prime Minister (or Premier).
The fact that that person has a majority in the Commons doesn’t mean they automatically become PM. The monarch must appoint that person to lead the government. That is a legal appointment under the Royal Prerogative. In the four countries I’ve mentioned, there is no legal definition of Prime Minister or Premier. That’s simply the customary title used for the person the monarch has appointed to lead the Government. If one person has a clear majority in the Commons, the monarch appoints that person automatically.
Once appointed, the PM then decides who will be appointed to lead the different ministries of government, and who will be Cabinet members. In the U.K., not all ministers are in Cabinet, only the heavy hitting ministries like the Exchequer, Justice and the Home Secretary. In Canada, all ministers are in Cabinet. (Dunno for OZ and NZ).
The monarch then appoints those individuals to their ministries. In the UK, the appointments are under the Prerogative; in Canada, the appointments are statutory. Either way, the appointment and the responsibilities of the Cabinet members are set out in an Order-in-Council, recommended by the PM and ordered by the monarch.
And I would respectfully disagree with Quartz’s characterisation of the people the PM appoints to ministries. Unlike the US system, where the President can appoint whomever he wants to the Cabinet, the PM in a Parliamentary system is constrained by his party’s fortunes in the election, and can only appoint MPs who have been elected to the Commons. The fact of their election means that they are significant political players in their own right, and a PM who ignores the different factions within his own party does so at his peril. The PM has to appoint MPs that represent all wings of the party, not just his own supporters - and that means that the Cabinet almost invariably has members who think they could do a better job and are plotting to supplant the PM!
For example, I’m sure PM May didn’t think of Boris Johnson as a supporter, but she had to include him in Cabinet initially because he represented a significant BREXIT faction in the Conservative Party. Similarly, in Canada in 1993, PM Chrétien had to appoint his major rival, Paul Martin, to Cabinet, because Martin had significant support in the Liberal caucus. And sure enough, ten years later Martin forced out Chrétien and became party leader and PM.
That’s how it works with a party with a clear majority. This post is long, so I’ll do another about minority governments, before the hamsters eat this one.