If a star/galaxy is moving towards us, then its light is blueshifted, and if it is moving away from us, then its light is redshifted. How do we exactly know that the color we are seeing is not part of the fuel burnt by the star/galaxy, and is instead caused by the Doppler effect?
If you had a simple slit spectroscope, and looked at an incandescent light, you'd see a smear of light with red on one end and blue on the other. This is because the filament is producing light by glowing from being heated.
If you looked at one of those orange colored sodium vapor street lamps, instead of a smear of color, you'd see a group of lines. This light is produced by ionizing the gas.
The lines represent specific frequencies of light coming from the lamp. You could add a horizontal scale and find that the lines represent a specific frequency in the light spectrum.
If the street lamp was coming at you at a significantly high speed, the individual lines would be shifted in frequency towards blue, but would still have the same pattern. Conversely, if the light was moving away from you, you'd again see the same pattern of light lines, but their frequencies would be shifted toward red.
This is what's being measured when the spectra of stars and galaxies are measured: not just what the color looks like, but whether the spectra of things like hydrogen, helium and iron are shifted in frequency towards red or blue.
So, it's the specific line patterns produced by these elements when they are ionized in stars that helps us identify them. Comparing the light frequencies of locally ionized elements to the frequencies coming from distant stars that tell us if the stars themselves are approaching or receding.