The cause of these changes are chromogenic bacteria that produce pigment through their metabolism. Chromogenic bacteria in the oral cavity are not pathological in themselves, but they create unpleasant pigmentation on the teeth.
It is actually an anaerobic bacterium Bacteroides melanogenicus which forms part of the natural flora of the oral cavity. However, with an increase in the number of bacteria in the oral cavity, poor oral hygiene, roughness of the tooth surface, smoking and other factors, pigmentation occurs on the teeth.