Ammonia is only one factor in aquarium health. Even with good ammonia levels, fish can die from high nitrite or nitrate, incorrect pH, temperature swings, low dissolved oxygen, or chlorine and chloramine in tap water.
Other causes include disease, parasites, stress from overcrowding or noise, poor diet, and new tank syndrome if the beneficial bacteria have not fully established.
Test all water parameters, perform a large water change with dechlorinated water, check for signs of disease, improve aeration, and consult a fish veterinarian if needed. Prevention involves proper cycling, regular maintenance, a balanced diet, avoiding overstocking, and providing a stable environment.