Did the Holy Prophet (sws) appoint a full time imam to run each mosque during his lifetime? If not, when was the imamat institution introduced? Outside of prayer times, were the mosques used as a civil secretariat or a qadi court to dispense justice?
Mainly the political leaders and prominent believers were appointed to lead the prayers in the mosques. There were no paid imams then. For a long time the state officials like governors, qadis and judges have been fulfilling the noble duty. Later on the believers no longer remained conscious of their religious duties and obligations and the government too lost interest in the religion when the people started appointed their imams for themselves.
As for the mosques, the Prophet's mosque in Madinah worked as political, social and educational center during the Prophetic and caliphal times. For detail please refer to: Mosques