I think that is a bit inaccurate.
In a republic the head of state is usually directly elected; in a constitutional monarchy, the head of state is usually hereditary. Whether the head of state has any real power varies greatly.
The head of government (e.g. the prime minister) is most often NOT directly elected at all, since most multiparty democracies apply parliamentarism, i.e. the parliament has the power to select and remove the head of government.
So the voters focus on voting for parliament members and the head of government is INDIRECTLY elected by the winning _coalition_, so the head of government usually represents a coalition rather than a party. This a bit more dynamic as the coalition can change in between elections when parties realign, sometimes resulting in a new head of government or an early election.