it's all in the setup; you'll notice that adverts for metal-cutting lathes usually specify the threads that they will cut as they come from the factory.
it is usually possible, given a sufficiently bored operator and some calculation, to get a screw cutting lathe to cut any thread, regardless of the ones the factory selected, but that requires modifications to the lathe and is thus the subject of another post.
there is a gear train (the 'change gears' and 'quick change box') on a metal cutting lathe, that allows the operator to set the ratio of rotational speeds of the chuck/spindle to the part that's called a lead-screw. a simple calculation will yield the ratio to set for any thread pitch; often there's a lookup chart right on the lathe near the quick change levers or on the change-gear cover.
there's usually (not always) a dial called the thread-cutting dial that tells the operator the relative position of the lead screw, the carriage and the spindle, so that the 'half nuts' (which engage with the leadscrew) can be engaged at the right point in the rotations of the screw and spindle.
that, with the various micrometer dials, allows the operator to engage the cutting action at the same point multiple times. . . .
then, with a suitably prepared cutter (the ability to precisely grind a threading cutter freehand is a good indication that you're dealing with someone who has some in-depth knowledge of machine tools, but cutters can be purchased for most common thread forms) one can cut any thread form and pitch desired by the simple expedient of making multiple passes, each slightly deeper than the last, making sure that every pass starts at the same point on the screw.
there's a little calculation to figure out how deep to cut, but it's basic trigonometry, and most of the common threads can be found on a lookup table. Machinery's handbook has a pretty comprehensive one, but there are plenty of free sources on the web.
TL;DR: the machine does most of the work in getting consistency; the operator is responsible for proper set-up and manipulating the controls at the right points in the cycle.