> In some countries, like Germany and Italy, the head of state is an elected president, usually an fairly elderly politician.
In Italy the only people elected by the citizens are the members of the Parliament.
The head of the state is elected by the members of the parliament every 7 years.
The head of the government is chosen ("invested") by the head of the state after a round of consultations with representatives of the political parties after the parliamentary election (basically the president asks "guys, who would you like as your own leader?"). The appointment of the head of the government is then approved (or, often, refused) by a parliamentary vote.
It was customary (before Berlusconi's times) for the winning party to elect its own representative as the head of the higher chamber. At the same time the losing party would get to elect the head of the lower chamber. (Yes, "lame duck" by design.)
All this complicated dance of indirect elections (that the current parties would like to remove) has been put in place after the WW2 to avoid too much power being in the hands of these high-profile figures or of a single party. "You have not been elected. We, the parliament are those who reign here." The head of the state cannot even address the parliament or get physically near the discussion hall without a written request from the MPs.