Is there a particular way we should observe when entering or leaving a mosque?
It is recommended that when entering a mosque, we put the right foot first and say: “My Lord, forgive me and open for me the gates of Your mercy.” On leaving, we put out our left foot first and say: “My Lord, forgive me and open for me the gates of Your bounty.”
But this is a recommended practice, which means that if we do not do it, we do nothing wrong. It is though an omission of what is preferable [and earns reward].