All perfect praise be to Allah, The Lord of the worlds. I testify that there is none worthy of worship except Allah and that Muhammad, sallallahu ‘alayhi wa sallam, is His slave and Messenger.
This money was raised to build a mosque, which is not possible, so if it is possible to build a mosque with this money in another place that needs a mosque, then that would be better because this was the intention of the donors and the purpose for which the money was collected. If this is also not possible and you cannot build a mosque in another place and there is a need to spend this money in buying a burial ground for the Muslims, then there is no harm in doing so, Allah willing. Some scholars held that it is allowed to spend endowed money for a purpose other than that for which it was endowed if it is more beneficial and better.
The Hanbali scholar Mustafa Ar-Ruhaybani wrote, “Shaykh Taqiyy Ad-Deen said, ‘It is permissible to change the condition set by the person who endowed property for a more beneficial purpose. For example, if the money was endowed to be spent on scholars of Fiqh or Sufis (ascetic worshipers) and there was a need for money to finance jihaad, then this money should be spent on the soldiers instead.’” [Matalib Uli An-Nuha fi Sharh Ghaayat Al-Muntaha]
Accordingly, there is no harm on you if you spend the mentioned amount of money to buy a burial ground for the deceased Muslims in this country if you cannot spend it to build a mosque or if buying a burial ground is more beneficial given the dire need for it, especially when you fear losing this money when the person entrusted with it passes away. Also, the intention of the donors is to earn much reward; so the greater the benefit that this money yields, the closer it is to the donors' intention.
Allah knows best.