well, first you have to calculate (estimate) how many votes you're short by, then send the order out to the printers, get them printed up, and then find the best time (3am?) to surreptitiously inject them with the uncounted ballots, and then allow the counting to proceed. These things take time, but rest assured, it's a well-oiled machine in operation.
First, though, they need to print enough to close the delta between the two candidates. Then they need a "reasonable" amount beyond that to make sure they have a comfortable lead in the event of a recount.
Depends on the state whether or not there are threshold for requesting recounts, how long after the election they can be requested, and whether there is a certain minimum margin before a recount is automatically performed.
In CA, for example, they have no automatic recounts. Anyone may request a recount.
The requestor must pay for the recount, but if the recount flips the results in favor of the
requestor, their money is refunded.
For multi-county or statewide races, the request must be made within five days starting
the 31st day after election day. For single-county races, the request must be made within
five days of the county canvass. No margin is required. There is no deadline for the
completion of voter-requested recounts. Deadlines vary for other types of requested
recounts.
Other states' recount rules may be much different.