The word imām simply means one who leads. It comes from the root word 'amma, which means someone who other people follow.
The Arabic word amām means front or forward, and imām, denotes that as well, because the leader or one who is being followed is going to be in the front. The term ummah also comes from the same root word as well.
The opposite of the imām is the ma'mūm, which means the follower (ma'mūmīn -followers). The plural for imām is a'imma.
For example, the person leading prayer is called imām jamā'ah, or leader of congregational prayer. The follower/s are called ma'mūm/ma'mūmīn.
The Quran makes reference to this term, using it for righteous leaders, but also using it for evil leaders as well (like surah tawbah, 12).
Therefore, the term imām can be used in different ways, depending on its context.
It could be imām of congregational prayer. The term imām could be used as a title for a scholar, like the local imām who is an Islamic cleric. It could be used for someone who aspires to become a leader among the righteous, like the verse:
وَاجْعَلْنَا لِلْمُتَّقِينَ إِمَامًا
It could be used as an honorific title for someone who was a great leader, like Imām Khomeini.
It could be imām of the four Sunni Madhhabs, like Imām al-Shafi'i.
It could be used as a title for the chief leader, or a ruler, or a caliph.
In our Shi'i context, we avoid using the word caliph as a title for our leaders and the successors of the Prophet (s.a.w), and we refer to them as Imāms, like Imām Ali, etc.
And Allah knows best.