Python: Array of objects error
Not sure this question is really suited here, but well…

 x = 0
 y = 0
 for row in range(rows):
     x = x + scene.formationArrayColumnMargin
     for ag in range(int(agentsPerRow)):
         y = y + scene.formationArrayRowMargin


y must be reset to zero each time you run outer x loop, otherwise it keeps growing. Something like that:

x = 0
for row in range(rows):
    y = 0
    x = x + scene.formationArrayColumnMargin
    for ag in range(int(agentsPerRow)):
        y = y + scene.formationArrayRowMargin