That's not the case. Hourly productivity decreases at some point.
The law of diminishing returns is at play here. Working longer hours leads to higher overall output up to a point as the marginal increase diminishes.
Then, at some point you are too tired and produces bad software that will cost to fix.
If your employer pays you a flat rate then it is profitable to make you work long hours up to the point when you start screwing up. If they pay you by the hour or if they pay you overtime, rationally they shouldn't push you beyond the point where your hourly output is too low to justify your pay.