Basically, Muslims can pray anywhere as long as the place is clean and dry e.g at home, office, open air areas etc. But, it is always preferable and meritorious to pray in congregation at a mosque. This gathering of Muslims at a mosque five times daily, is a step towards the establishment of healthy social relations, equality, unity, discipline as well as enhances the prestige of Islam. Moreover, the reward for congregational prayer is multiple times that of praying individually and so Muslims prefer going to the Mosque to say their prayers.
It is also important to know that Muslims offer every prayer, be it at home or in the Mosque, facing towards Mecca, a city in Saudi Arabia which known as the Qiblah. The Qibla itself is a single box like room, built by Prophet Abraham and his son Prophet Ismail.
Now you May have noticed that for the Friday Mid-day Prayers, all the Muslims visit the mosque. This is once a week congregation that holds special significance in Islam and this prayer has to be offered in the Mosque and cannot be offered individually at home or elsewhere.