This is an interesting problem.
The main issue here is that depending on frame rate, dt and bullet speed, you will trigger the overlap condition at different X locations on each wall. If you look very carefully (or look carefully and increase bullet speed), you will see that sometimes the squares overlap the walls by different amounts before they change diection, then they will start at different locations and change the spacing.
To make it look more consistent, one idea is to detect how much the overlap is and set the block back to where it 'should' be when it reflects back in the other direction.
Try this and let me know how it works in your testing. The formulas can be simplified, but I left them as is, so it would be easier to see what the calculations are doing.
It does start to fail if you increase the bullet speed to be so high that in one frame two squares would overlap the wall, if you need to deal with that case, you will need to do more work.