I bought better quality shelving (Trainshelf) and all I have to do is put a pin into a slot that is already in the extruded shelf. I don't recall how I spaced the shelves, other than measuring what clearance I needed between the shelves and the top of the train on the shelf below. Then I used a level.
My advice for attaching the shelves to the wall is to go to a home improvement store and buy screws used to attach metal siding to a pole building. They have a hex head on them, so you can use a socket to drive them in without stripping the screws and rubber grommets on them to snug the shelves up nicely.
Here is a typical joint
The upper set of shelves runs 36 feet in length and the bottom ones must run 28 feet in length.