Please read the article How are laws made in the Caliphate? for a detailed account of the lawmaking process in the Islamic State.
During the Rightly Guided Caliphate all the Caliphs were selected freely by those who represented the opinion of the Muslims. They were given the Bay’ah (Pledge of Allegiance) on the basis of meritocracy and each of them had huge political experience. Abu Bakr, Umar, Uthman and Ali had all held the position of Wazir (Delegated Assistant) which is the highest government position after the Caliph. When we look to their ages we see they were all elder statesman (excluding Hasan who became Caliph during the civil war).
The Messenger of Allah ﷺ said: “The example of my Ummah is like the rain. It is not known whether the initial part or the latter part (of the rain) is good.” (Ahmad, Tirmidhi)
The Messenger of Allah ﷺ said: “Verily you shall conquer Constantinople. What a wonderful leader will her leader be, and what a wonderful army will that army be!” (Ahmed, Al-Hakim)
A Muslim woman was captured by the Romans and held in a place called‘Amuriyyah. Not content with only capturing her they tried to dishonour her as well. Frightened and alone she called out the name of the Khaleefah, “Ya Mu’tasim”. A man witnessed this incident and rushed to the Khaleefah informing him of what had happened. When he heard the plight of this woman Mu’tasim responded bravely, “Labbaik (I am here at your call).” He prepared a large army and set off for battle to rescue the woman. Mu’tasim’s army conquered the enemy and entered ‘Amuriyyah. After destroying the enemy stronghold, they came to the woman and freed her. (Ibn Athir, Kamil)
The Messenger of Allah ﷺ said: “The best people are those of my generation (Sahabah), and then those who will come after them (Tabi‘in), and then those who will come after them (Tabi‘ al-Tabi‘in), and then after them, there will come people whose witness will precede their oaths, and whose oaths will precede their witness.” (Bukhari)
The Messenger of Allah ﷺ said: “The Khilafah in my Ummah after me will be for thirty years. Then after that there will be Mulkan ‘aduudan (hereditary rule).” (At-Tirmidhi)