Praise be to Allah.
Building mosques, maintaining them and preparing them for the worshippers is one of the best of good and righteous deeds for which Allah has decreed an immense reward. It comes under the heading of ongoing charity (sadaqah jaariyah) which will continue to bring reward even after a person’s death. Allah, may He be exalted, says (interpretation of the meaning):
“The Mosques of Allah shall be maintained only by those who believe in Allah and the Last Day; perform As-Salat (Iqamat-as-Salat), and give Zakat and fear none but Allah. It is they who are expected to be on true guidance”
The Prophet (blessings and peace of Allah be upon him) said: “Whoever builds a mosque, Allah will build for him a house in Paradise.” Narrated by al-Bukhaari (450) and Muslim (533), from the hadith of ‘Uthmaan (may Allah be pleased with him).
For more information, please see the answer to question no. 146564
The basic principle is that it is obligatory to carry out the wishes of the one who left that endowment (waqf), and it was narrated that there was scholarly consensus on this point in general terms.
Al-Hajjaawi (may Allah have mercy on him) said in Zaad al-Mustaqni‘: It is obligatory to carry out the wishes of the one who made the endowment.
Shaykh Muhammad al-Mukhtaar ash-Shanqeeti (may Allah preserve him) said: That is, it is obligatory upon the one who has been appointed to look after the endowment to act in accordance with the wishes stipulated by the one who made that endowment.
If the one who made the endowment stipulated conditions, or it set out specific signs or characteristics to determine who is entitled to benefit from his endowment, then it is obligatory to act accordingly, and it is not permissible to ignore these conditions or tamper with them. That is according to the consensus of the scholars, may Allah have mercy on them. When ‘Umar ibn al-Khattaab (may Allah be pleased with him) wrote his will, in which he left his land in Khaybar as an endowment (waqf), he entrusted supervision of it to the Mother of the Believers Hafsah (may Allah be pleased with her), then after her to the most mature and just of his descendants, and he stipulated conditions on how the income from the endowment was to be spent and used. The practice among the leading scholars and judges of the Muslims has been that the wishes of the one who left the endowment should be followed and it is not permissible to cancel them, alter them, change them or distort them.
Hence the author said “it is obligatory”, which indicates that the one who goes against that is sinning. Hence it is not permissible to alter these instructions, unless the qaadi determines otherwise in exceptional circumstances, which we will explain below, in sha Allah. However the basic principle remains that it is obligatory to act in accordance with these instructions and carry them out, and the conditions may vary. If a person leaves a piece of land or anything else as an endowment, he may stipulate that it is to be cared for by a particular individual, or he may stipulate a particular beneficiary for the endowment, or he may stipulate that this beneficiary should have certain characteristics.
End quote from Sharh az-Zaad.
To sum up:
It is not permissible to transfer the endowment to someone else, or to change the instructions of the one who made the endowment, unless it is no longer possible to carry out the terms of the endowment as stipulated.
Please see also the answer to question no. 140176
Based on that, what you must do is act in accordance with your grandmother’s wishes, in compliance with the shar‘i texts to that effect, as mentioned above. Even those scholars who say that it is permissible to change the endowment or change its conditions meant that that applies only if it is better for the endowment and will enable people to benefit from it more completely, and there is no interest to be served by changing or annulling the endowment.
And Allah knows best.