All perfect praise be to Allaah, The Lord of the Worlds. I testify that there is none worthy of worship except Allaah, and that Muhammad is His slave and Messenger.
Performing obligatory prayer in the mosque is a religious obligation (on Muslim men), and failing to observe it without a Sharee'ah-approved excuse is forbidden. Muslim scholars held different opinions in this regard. Hence, if someone takes a vow to perform the obligatory prayers in the mosque, then he is obliged to deliver on his vow. ‘Aa’ishah reported that the Prophet, sallallaahu ‘alayhi wa sallam, said: "Whoever vowed to obey Allaah, the Exalted, must obey Him; and whoever vowed to disobey Allaah, the Exalted, must not disobey Him." [Al-Bukhari]
However, if the vow-taker said, "I vow to perform two Rak‘ahs for every obligatory prayer that I fail to perform in the mosque," in order to urge himself not to miss the prayer in the mosque, then such a vow is known as a vow of lajaj (i.e. anger). It is enough for the vow-taker, in that case, to offer an expiation like that of breaking an oath. The determining factor in considering a vow to be that of lajaj is the person's intention to urge himself to do something or abstain from doing something by rendering the performance of a righteous act that brings him closer to Allaah conditional on the performance or nonperformance of a certain act. There is no harm if the person fulfills such a vow, but he is not obliged to do so; it is enough for him to offer an expiation like that of breaking an oath.
Allaah Knows best.