Praise be to Allah.
Regarding the Mushafs that are placed in the mosque, it is not permissible to take them to another mosque unless they are no longer being used because the mosque has been demolished, or they are clearly surplus to needs, in which case they may be taken to another mosque. It is not permissible for anyone to take them home.
Shaykh Ibn Baaz (may Allah have mercy on him) said: If the small mosque does not need some of the Mushafs that are in it, then there is nothing wrong with moving whatever is not needed in that mosque to another mosque that needs them, because the purpose behind that is for the worshippers to make use of those Mushafs. But to be on the safe side, you should ask the imam for permission to do that, because he knows best what is needed in the mosque. End quote from Majmoo‘ al-Fataawa (20/15).
Your shaykh made a mistake by taking them to the second mosque, unless the Mushafs were given as a waqf to the memorization circle, and not to the first mosque. In that case, he could move them to the place where the memorization circle was held, or if they were surplus to the needs of the mosque.
With regard to your taking the Mushaf home with you, that is haraam, and what you must do now is return it to the first mosque.
It says in a fatwa of the Permanent Committee (16/19): Is it permissible to take a Mushaf from the Haram to read it at home?
Answer: Regarding Mushafs and books that are given as a waqf to be used in a specific place, it is not permissible to take them elsewhere, whether that place is a Haram or anywhere else, unless the place is no longer in use, in which case they may be moved to a place where they will be used for a similar or better purpose. End quote.
Shaykh ‘Abd al-‘Azeez ibn ‘Abdullah ibn Baaz, Shaykh ‘Abdullah ibn Ghadyaan, Shaykh ‘Abdullah ibn Qa‘ood.
Shaykh Ibn ‘Uthaymeen (may Allah have mercy on him) said: We must understand, with regard to items given as waqfs (endowments) to mosques, that it is not permissible for anyone to remove them from the mosque, even if that is in order to make use of them. So it is not permissible to take a Mushaf from the mosque to read it at home, or to take any book that was given as a waqf to the mosque to study it at home, or to take out any electrical equipment and the like to make use of it at home. Whatever has been given specifically to the mosque, it is not permissible to take it out of the mosque.
Some people think that because the Mushafs in the mosques are a public waqf for everyone who enters the mosque, that it is permissible for a person to make use of them on his own at home. But this is wrong thinking, because you might take it, then some people may come to the mosque who need it, in which case you will have deprived them of it. Even if there are many Mushafs in the mosque, many people may come to the mosque.
Whatever the case, anything that is given specifically to the mosque, it is not permissible for anyone to keep it at home for his own use, or keep it for his own use in the mosque, meaning that he picks the Mushaf up and reads from it, then when he has finished he hides it in a place that no one knows except him, so that he can read from it when he goes to the mosque. That is because things that are for public use should remain available to everyone.
With regard to the question of the one who said that his friend gave him a Mushaf that he took from the mosque, what he must do is return this Mushaf to the mosque from which his friend took it.
End quote from Fataawa ash-Shaykh Ibn ‘Uthaymeen, Noor ‘ala ad-Darb (16/2).
And Allah knows best.