If you define a function called "draw" in your code, then that function will get called repeatedly, about 60 times per second. This is typically used for creating animations, in combination with incrementing variables that affect the shapes drawn. To re-paint the entire canvas for each frame, use the background() command. Otherwise, new shapes will be drawn on top of the previous canvas.
Note: The default frame rate can be changed with the