Moving cubes looks broken when they move vertically

I am going to move a line of cubes vertically or horizontally. As you see, when I move cubes horizontally, there is no problem. But when I try to move those vertically, it looks broken.

The size of each cube is 1, and distance between cubes is also 1. Of course because the gap between cubes is not what I want, I cannot change distance. Is there anyway to make it look natural?

The thing thats wrong here is that some are being rendered on top of others. For example in the vertical move photo you can see that the bottom right cube is rendering over the middle cube and so on.

How are you moving these? Are you changing an axis that you should be changing?