Special 1/4" presser feet are available for most modern sewing machines. The 'foot' is quite a bit longer than normal, which makes it easy to stitch a perfect seam.
A simple technique for accurate machine sewn seams involves a ruler and masking tape. Lower your machine's needle at the 1/4" mark. Leave the ruler in place and place several layers of tape one on top of the other butted up against the ruler's edge. This will leave a build up of tape that can be used to guide your pieces under the needle at just the right spot. Check the tape periodically to be sure that the mark has not shifted.