This is because when some hypocrites raised objections against the Prophet ﷺ concerning alms, Allah clarified that He Himself had apportioned them, defined their rulings, and taken charge of the matter; He did not leave their distribution to anyone else.
Shaykh al-Islam Ibn Taymiyyah (d. 728 AH) said, “They must be allotted to the eight categories if they are all present; if some are absent, then to those who are present, and they may be transferred to wherever those recipients are found.”
He also stated, “They should be given only to those who will use them as an aid in obeying Allah, for Allah prescribed them as assistance in His worship for the believers who need them or those who help them. A needy person who does not pray is not to be given any share until he repents and commits himself to performing the prayer.”
Accordingly, it is not permissible to spend zakah on other charitable ventures—such as building mosques or schools—that Allah has not specified. The Exalted says, “Charitable alms are only for the poor and the destitute…” (Qur’an 9:60). The word “only” (innamā) conveys restriction: it affirms the ruling for what follows it and negates it for everything else. In other words, alms are not for anyone besides these recipients; they are exclusively for them. Allah named the eight categories to make it clear that zakah may not be diverted from them to anyone else.