The display is double buffered.
This means there are two buffers for your rendering: the front buffer and the back buffer. The front buffer is what is shown on the monitor. The back buffer is where drawing happens.
When the program calls the window's display() function, the two buffers are swapped.
If the window isn't cleared each frame, you have to make sure every pixel of the window is overwritten by something. For example drawing a full window background sprite, or a tile map, etc. What you are drawing on top of isn't the last frame rendered, but the second last frame, since the last frame is in the other buffer.
If pixels aren't overwritten, you'll get flickering anywhere the two buffers don't have the same pixels.