(…أَن يَعْمُرُوا مَسَاجِدَ اللَّهِ…) (to maintain the mosques of Allah…): ‘to maintain the mosques’ could either refer to sit in the mosque, or to take care of its affairs. Allah (swt) forbids the polytheists from both of these activities.
(…شَاهِدِينَ عَلَىٰ أَنفُسِهِم بِالْكُفْرِ ۚ…) (Witnessing against themselves with disbelief.): The mosque is a place assigned for the worship of Allah (swt), and the Sacred House (the Kaaba) is the first House established for humanity for the worship of the One true God, as Allah (swt) says:
إِنَّ أَوَّلَ بَيْتٍ وُضِعَ لِلنَّاسِ لَلَّذِي بِبَكَّةَ مُبَارَكًا وَهُدًى لِّلْعَالَمِينَ
(The first House (of worship) appointed for men was that at Bakka: full of blessing and of guidance for the worlds.) (Ali-‘Imran: 96)
Therefore, it is not rationally for the polytheists to maintain places of worship for Allah, as they do not believe in Him. How would they maintain His mosques in general, and the Sacred Mosque (Masjidil Haram) in particular?
(…أُولَٰئِكَ حَبِطَتْ أَعْمَالُهُمْ…) (For those, their deeds have become worthless…): Whatever they do in terms of providing water for the pilgrims and taking care of matters related to the Sacred House, all these actions will be in vain. Their deeds have been thwarted and have become worthless because they do not believe in Allah (swt).