The question was posed on islamQA is as follows:
[h=4]65944: Why is the Prophet’s grave in his mosque even though it is forbidden to take graves as places of worship?[/h]
I didn't read the answer, because I have a simple one.
The tradition of the prophets and messengers of Allah is that they be buried where they die.
When the Prophet pbuh passed away, his house was not a part of the masjid, but annexed to it.
His house is still annexed to it, and no one worships inside of it - the area is cordoned off.
So the question itself is wrong. The grave is not in the masjid itself, it is in the annexed building next to it, even after all the construction work to expand the masjid, the grave was not moved and neither was the house of the prophet pbuh, they carefully built around it, taking care not to let the materials fall in on itself by strengthening the walls etc.
Scimi