How to create an array of objects with offset in python
Currently your duplicating an object and moving it by -(2a + 1.5) units on the x axis. This doesn't give you a offset between the objects as objects are still exactly 2 units away of each other (because a changes by 1).

You should multiply formationArrayX with a, instead of adding it. To get something similar to the screenshot you posted, increase formationArrayX to something like 3. You also don't need offset2 then.

Also note, that your current code duplicates all objects you added before in each step. Only the last one created is offset, all others stay at the initial position. This is because the duplicate operator duplicates all selected objects and you don't un-select objects after translating

EDIT: This answer was only valid for an earlier version of the opening question. Code has been changed since then.