You need first to know the meaning of the term (Imam). Imam means a divine leader. The divine leader for human beings can be the Prophet of his time, or a successor of a Prophet. Prophet Ibrahim was appointed by Allah as divine leader (Imam). (2:124). This appointment came long after he was appointed as a Prophet then a messenger.
Prophet Muhammad (SAWA) is greater than Prophet Ibrahim and he Ws appointed as the divine leader for all human beings. His twelve successors are the Imams after him. Imam does need to be a Prophet but divine leader.
Wassalam.