For each scale, the NMRA produces a steel track gauge. You need one, unless you only buy commercial pre-fabricated snap-track. For everything else, including commercial flextrack and turnouts (and especially if you hand-lay your track), you need one of these for your chosen scale. For S-scale the NMRA sells one for Sn3, but not for standard-gauge track. This was because the original NMRA standards measurements it had created for S-scale standard-gauge weren't 100% accurate. The NASG (National Association of S Gaugers) revised those measurements and eventually the NMRA adopted those standards. In the meantime, the NMRA never made an S-scale version of their gauge, so the NASG made it themselves. This is what is shown in the photo. Through mutual cooperation, both the NMRA and the NASG now sell the S standard-gauge gauge and the Sn3 narrow-gauge gauge.
(external link: NASG Standards Gauge)
These gauges help you verify that the rails are the correct distance apart from each other. They also have notches for verifying that the locomotives' and cars' wheels are spaced correctly so that they will ride on the rails correctly. Finally, they provide tabs to check the proper distances of the various rails of a turnout. When you buy the gauge, it will come with a sheet that explains how to use each of the measurements. Note that this NASG gauge does not function as a clearance gauge (the NASG now sells those separately).
Although the above-mentioned gauge is the official authority on rail spacing, they are not easy to use when you are actually hand-laying rail. They are really more intended for checking existing track, rather than track construction. The gauge is not self-supporting, and the small tabs are hard to keep on the rails while you are handling other track-laying tools. So, most scales have manufacturers who make additional gauges out of various materials to help with this process. Shown in the photo is a set of three code 83 S-scale track gauges I bought from Tomalco Track. I also have a set for code 100 rail. With these gauges, I recommend at least three. Three of them gives me reliable confidence that the rails are lined up correctly. Buy as many of them as you see fit, because they are extremely handy; the more you have, the longer of a section of track you can accurately lay out before attaching the rail. The gauges' flat tops are perfect for placing weights on them to weigh the rails down while you are working on the track.
(external link: Tomalco Track)
I also use these to lay curved track, although some people prefer the three-point gauges for that. What you have to do with these gauges is to space them closer together to guarantee that the two rails remain accurately spaced throughout the curve. That is where more of these gauge comes in handy if you are laying out long curves.
Some people don't like that these gauges are made out of metal, because if the track is "live", they cause a short. Therefore some manufacturers make theirs out of a non-conducting material. However, the downside of some sort of plastic-based gauge is that if you have a soldering iron nearby to solder something to the rails, the gauge could melt. Both are valid solutions; you just have to pick the one that fits your working habits the best. Since my layout is "dead-rail", I never have current applied, so metal ones are perfect for me.