Al-Ḥāfiẓ Ibn Ḥajar said: “It seems that the Prophet—peace and blessings be upon him—realised he would depart this world because of that illness, and he feared that his grave might be glorified as the graves of earlier peoples had been. Therefore he cursed the Jews and the Christians as a rebuke to anyone who does what they did.”
I say: that is, anyone from this ummah. In the next ḥadith (6) there is an explicit prohibition addressed to them regarding this—so take note.
5 – ʿĀʾisha (may Allah be pleased with her) reported: During the Prophet’s final illness, some of his wives spoke about a church in Abyssinia known as Māriyā. Umm Salama and Umm Ḥabība had been to Abyssinia and described its splendor and the images it contained. [When the Prophet—peace and blessings be upon him—heard this,] he raised his head and said, “When a righteous man died among those people, they would build a mosque over his grave and set up those images. Such people are the worst of Allah’s creation [on the Day of Resurrection].” (1)