So like the traditional artist, the computer will first draw the images that are behind everything, and layer the subject and foreground on top of it. This is referred to as the “drawing order”.
Switch the commands around, and you will not see the yellow circle at all: it was drawn before the red circle and thus ‘behind’ it. In programming, if you tell a computer to draw a red circle, and then afterwards tell it to draw a smaller yellow circle, you will see the small yellow circle overlap the red circle. Or to first draw a line art and then color it in. In traditional art, it is not uncommon to first draw the full background before drawing the subject.
The layer stack is pretty awesome, and it's one of those features that make digital art super-convenient. To fill line art comfortably, it's best to take advantage of the layerstack.
This tutorial is adapted from this tutorial by the original author.