The reasons why the tails of koi fish may rot could include the following:
Water Quality Issues: Improper water quality management or insufficient filtration can lead to a large amount of pollutants in the water, which easily breeds bacteria and causes local skin erosion.

External Injuries: The tail area of koi fish is relatively fragile. When it gets hit, it is prone to local damage, resulting in swelling, redness, and pain. If not treated in a timely manner, it will cause local suppuration.
Bacterial Infections: Infections by various bacteria such as Aeromonas sobria and Aeromonas hydrophila can cause congestion and inflammation of the caudal fin, with the ends of the fin rays being milky white and eroded. In severe cases, the entire tail may rot away.
Other Diseases: Diseases like folliculitis, seborrheic dermatitis, and saprolegniasis can also lead to tail ulceration.
Preventive Measures Include:
Keep the Water Clean and Hygienic: Regularly change the water and clean the fish tank on a regular basis to avoid fish getting infected with diseases due to water quality problems.
Proper Diet: Provide nutritionally balanced bait to keep the fish in good health.
Isolate Sick Fish in a Timely Manner: When fish get infected with diseases, isolate the sick fish for treatment promptly to prevent the spread of the disease.
Pay Attention to the Maintenance Environment: Keep the maintenance environment clean, well-ventilated, and with sufficient sunlight to provide a healthy living environment for the fish.