How does scaling a geometric shape enable precise repetition of the materials on different surfaces?

Just like the diagram below, this is what I aim to achieve. In Blender, I simply created a rectangle. Each face was assigned a different material, which enabled the repeated display of the materials, but there was a slight offset in position. How can I align the edges?