In fact, only in the first case (a nearby body moving away from the earth) is the redshift caused by the Doppler effect. You've experienced the Doppler effect if you've ever had a train go past you and heard the whistle go to a lower pitch (corresponding to a longer wavelength for the sound wave) as the train moves away. The Doppler effect can happen for light waves too (though it can't be properly understood without knowing special relativity). It turns out that just like for sound waves, the wavelength of light emitted by an object that is moving away from you is longer when you measure it than it is when measured in the rest frame of the emitting object.
In the case of distant objects where the expansion of the universe becomes an important factor, the redshift is referred to as the "cosmological redshift" and it is due to an entirely different effect. According to general relativity, the expansion of the universe does not consist of objects actually moving away from each other - rather, the space between these objects stretches. Any light moving through that space will also be stretched, and its wavelength will increase - i.e. be redshifted. …
Practically speaking, the difference between the two (Doppler redshift and cosmological redshift) is this: in the case of a Doppler shift, the only thing that matters is the relative velocity of the emitting object when the light is emitted compared to that of the receiving object when the light is received. After the light is emitted, it doesn't matter what happens to the emitting object - it won't affect the wavelength of the light that is received. In the case of the cosmological redshift, however, the emitting object is expanding along with the rest of the universe, and if the rate of expansion changes between the time the light is emitted and the time it is received, that will affect the received wavelength. Basically, the cosmological redshift is a measure of the total "stretching" that the universe has undergone between the time the light was emitted and the time it was received.