Koi and goldfish color changes are USUALLY genetic but sometimes you’ll see a koi or goldfish turning black. USUALLY this is from a crashed pH, chronic parasitism, or ammonia-burn. The following test kit, tests for EVERYTHING. It’s 16 bucks and takes 30 seconds to run.
Sometimes the blackening is INTENTIONAL by breeders in Asia who will blacken Sarassa goldfish to create “tricolors”. The black departs the fish within a month.