At each epoch, the generator makes a number of predictions (it creates forged MNIST images) and the discriminator tries to learn how to produce forged images after mixing the prediction with real MNIST images. After 32 epochs, the generator learns to forge this set of handwritten numbers. No one has programmed the machine to write, but it has learned how to write numbers that are indistinguishable from the ones written by humans. Note that training GANs can be very difficult because it is necessary to find the equilibrium between two players. If you are interested in the topic, I'd suggest you have a look at the series of tricks collected by practitioners (https://github.com/soumith/ganhacks).
Let's look at a number of practical ...