Genetics may influence color change. Some goldfish change color over the course of their lifetimes. This has to simple do with their genes.
Lighting: The amount of lighting also has to do with color. Goldfish which are kept in brightly lit aquariums will have brighter colors than those who live in poorly lit aquariums.
Food: Color enhancers are natural substances which are present in nature. Aquarium foods which contains color enhancers can help your goldfish have a bright color. Carotenoid is an example of a natural color enhancer.
Disease: Sometimes, color change can also be due to disease or an infection. Curing this will help your fish regain the original color.