The nicotine and tar in tobacco can easily stain on surfaces of teeth or into cracks on enamel and pores in dentine, causing a yellow brown or black discoloration.
This heavy smoker's teeth hadn't been cleaned for years. The mixture of tobacco stains and tartar presented on most teeth. After the thorough clean, all stains on surfaces and tartar were removed. But the stains have settled deep into the cracks of enamel and penetrated into the dentin on the edges of the teeth, which were exposed because the enamel have been worn off.
A much better result would've been achieved if the patient had wanted professional teeth whitening.