Surah As-Saff(61), Verse 1:
سَبَّحَ لِلَّهِ مَا فِي السَّمَاوَاتِ وَمَا فِي الْأَرْضِ وَهُوَ الْعَزِيزُ الْحَكِيمُ
Whatever is in the heavens and on earth, let it declare the Praises and Glory of Allah: for He is the Exalted in Might, the Wise
(1) It is permissible to buy these places for turning the evil into good
“…Help ye one another in righteousness and piety, but help ye not one another in sin and rancour: fear Allah: for Allah is strict in punishment.” (Qur’an-5/2)
If those evil places was bought for purpose of evil then it is punished by ALLAAH very painfully and severely but if those evil places is bought for good purpose and change them into mosques or madarsa then you have do what LORD the Most High loves. You will be rewarded,InshaALLAAH.
When the Prophet (ﷺ) arrived Medina he dismounted at `Awali-i-Medina amongst a tribe called Banu `Amr bin `Auf. He stayed there For fourteen nights. Then he sent for Bani An-Najjar and they came armed with their swords. As if I am looking (just now) as the Prophet (ﷺ) was sitting over his Rahila (Mount) with Abu Bakr riding behind him and all Banu An-Najjar around him till he dismounted at the courtyard of Abu Aiyub’s house. The Prophet (ﷺ) loved to pray wherever the time for the prayer was due even at sheep-folds. Later on he ordered that a mosque should be built and sent for some people of Banu-An-Najjar and said, “O Banu An-Najjar! Suggest to me the price of this (walled) piece of land of yours.” They replied, “No! By Allah! We do not demand its price except from Allah.” Anas added: There were graves of pagans in it and some of it was unleveled and there were some date-palm trees in it. The Prophet (ﷺ) ordered that the graves of the pagans be dug out and the unleveled land be level led and the date-palm trees be cut down . (So all that was done). They aligned these cut date-palm trees towards the Qibla of the mosque (as a wall) and they also built two stone side-walls (of the mosque). His companions brought the stones while reciting some poetic verses. The Prophet (ﷺ) was with them and he kept on saying, “There is no goodness except that of the Hereafter, O Allah! So please forgive the Ansars and the emigrants. ”
Sahih al-Bukhari 428
from the above mentioned hadith prophet intended to purchase land of banu Najjar to convert it into masajid even tough that land contained the graves of pagans. But later it was dugged up.
CONCLUSION : buying the places of wines and dancing for the purpose of converting the masajid is permissible from the above hadith
ALLAAH knows best