Measure the diagonal corners of your shelving to determine how far out of square it is. Place the end of the tape measure on an upper corner and measure across to the opposite bottom corner. Repeat this on the opposite side, once again measuring from the top corner across to the diagonal bottom corner.
Subtract the difference between the two measurements to calculate the amount that your shelving is out of square. In order to return the shelving back to square lightly push the top corner of the side with the shorter measurement. You will most likely need a second helper to do this. As your helper holds the shelving, measure the diagonals again. The shelves are square once your measurements are equal on both diagonals.
Drill a small hole with a cordless drill and bit in the back of the shelving and into a wall stud while your helper holds the shelf at square. Drive a screw through the predrilled hole into the wall stud to anchor the shelf in place and square. If more screws are required now is the time to add them. Alternatively you can use a hammer and nail to hold the shelf in place.