People can't live without water. As a kind of clean water and high-quality drinking water, tap water is more and more widely used in daily life, and is also favored by consumers. However, a large amount of industrial waste water and some toxic substances are produced during the water supply process, causing harm to human body. Therefore, it is necessary to take reasonable and effective measures to reduce the generation of these hazardous factors, so as to ensure the safety of water quality. Most of the traditional sewage treatment technologies rely on manual, mechanical or chemical methods for treatment, which consumes a lot of water resources. Moreover, with the continuous improvement of environmental protection requirements and the introduction of relevant laws and regulations, such sewage treatment methods are gradually replaced by green, intelligent and other new technologies. Advanced technologies such as clustering algorithm and machine learning (ML) provide new ideas to solve this problem. They have strong generalization ability and can automatically adjust their combination strategies according to the differences between different categories, thus achieving more efficient solution to pollution problems in complex environments. This paper introduced the main components of the water treatment system in the waterworks, and analyzed the current situation of water pollution treatment. At this stage, a series of problems in the water plant have been pointed out, and corresponding countermeasures have been put forward, such as optimizing the sewage treatment process, establishing a reasonable and effective scheduling mechanism, and strengthening the construction and management of sewage pipe network, which are of great significance to improve the water treatment rate and reduce energy consumption. The traditional governance methods were compared with the prevention model based on clustering algorithm and ML. The results showed that the optimized prevention and control model had strong pertinence, and could better achieve the water quality prediction function. The service quality has also improved by about 10.79%, which has achieved the goal of efficient and economic water pollution control, and has played a certain reference role for future practical work.