"How does the leading party decide the PM, and how?"

The Prime Minister is a member of the House of Representatives who leads the parliamentary party, or coalition of parties, with the support of the majority of members in the House. Each political party has its own arrangements for electing its leader.

For the Liberal Party and The Nationals coalition the Prime Minister will be the leader of the Liberal Party of Australia. This person is chosen in a vote of the Liberal Party members elected to the Australian Parliament. For the Australian Labor Party (ALP) the Prime Minister will be chosen by a combined vote of members elected to the Australian Parliament and the ordinary members of the party. The votes of the ALP members of parliament count for 50 per cent in the ballot and the votes of the ordinary party members count towards the other 50 per cent.

diagram to help explain How does the leading party decide the PM, and how?