“…while you are in retreat in the mosques” (Al-Baqarah 2:187) — He did not say “in the shrines.”
He, exalted is He, also said:
“Say, ‘My Lord has commanded justice, and that you set your faces upright at every mosque…’” (Al-Aʿrāf 7:29)
And He said:
“Only those who believe in Allah and the Last Day, establish the prayer, give the zakat, and fear none but Allah are the ones who maintain the mosques of Allah; such people are expected to be among the rightly guided.” (At-Tawbah 9:18)
And He said:
“The mosques belong to Allah, so do not call upon anyone along with Allah.” (Al-Jinn 72:18)
The Messenger of Allah ﷺ said, “A man’s prayer in the mosque surpasses his prayer in his house or in the marketplace by twenty-five degrees.” He also said, “Whoever builds a mosque for Allah, Allah will build for him a house in Paradise.”
As for graves, the Prophet ﷺ prohibited turning them into places of prayer, and he cursed those who do so; one of the Companions conveyed this from him.