The Depth Buffer holds the "depth" of the pixel in the scene. When OpenGL renders your geometry, each fragment (pixel) is compared against the depth buffer's value at that point. If that fragment has a z value lower than the one in the buffer, it becomes the new lowest value, and thus the pixel to be rendered. If not, don't render it - there's something closer that's blocking it. That's the gist of it - you can read into the specifics yourself.
Now, what happens when the scene changes? You want to clear the screen so you redraw everything, but you also want to clear the depth buffer. Why? Because otherwise all the new pixels will be compared against the depth values from the previous frame. That doesn't make sense - they should be compared against those in the frame they're in! You are correct in your reasoning.