A loop inside a loop
One loop draws a row. To draw a whole grid, put one loop inside another. The outer loop steps down the rows (y), and for each row the inner loop runs all the way across the columns (x).
If the outer loop runs 3 times and the inner loop runs 3 times, the inner body runs 3 × 3 = 9 times total — one shape per grid cell.
Two counters
Use a different name for each counter — like x and y — so the inner loop doesn't overwrite the outer one. Each shape's position comes from combining both.
Change the < 3 to a bigger number and the spacing to match, and you can tile the canvas with dozens of shapes from just four lines of code.