Goldfish tend to change color. Most change during the first year of life, but others change throughout their lifetimes. Inexpensive goldfish change in unpredictable ways because their parentage is uncertain and their color genes represent a random mix. Expensive "purebred" goldfish should exhibit significantly more predictable changes, achieving similar coloration of their parents as they mature. But be warned: If you purchase young (under a year or so), high-quality goldfish you cannot be certain that the colors you see are the colors you'll end up with a year later.
The single most important determinant of goldfish coloring is genes. What they inherit from mom and dad makes all the difference.
And keep this in mind always: Goldfish are not supposed to be “gold”, or any other color for that matter (they are a drab olive naturally).
[Sorry if this gets quite technical]
While we know how a goldfish changes color, no one has defined “why” a goldfish changes color. Scientists have identified two types of color changes in fish: physiological and morphological. Physiological color changes are due to the spreading out or aggregation of chromatosomes. When the chromatosomes are spread throughout the cell, the color is more pronounced to the naked eye. However, when the chromatosomes aggregate in the center of the cell, the color is muted or not visible. Morphological color changes, on the other hand, are due to a change in the number of chromatophores. So a fish that loses a number of melanophores will appear lighter, and a fish that gains melanophores will appear darker. Physiological color changes can become morphological color changes over time. For example, a fish that is kept in a tank with a dark background and dark rocks will become darker, initially because of movement of melanosomes in the already existing melanophores. However, if enough time goes buy, the fish will start to produce more melanophores and then the color change is considered morphological.