I found some code online which will move a box across the screen, then reset it after the box hits the end of the screen.
Here is the code:
OpenGL is a drawing API. When you call drawing functions, things are literally drawn to the framebuffer the very moment you issue the draw call -- well actually OpenGL batches up all the commands internally and processes them in order. But when OpenGL is about to process those drawing calls, it will draw to the framebuffer with the matrices set to the state at this specific position in the batch.
So to reemphase this: OpenGL does not do any kind of scene management, it just draws things to the framebuffer in the order and way you issue the drawing commands. You send a triangle: OpenGL will transform and draw it. There's no scene internally built. Once you understood this it becomes trivial to understand how the matrix stack can do its "magic".