That just makes no sense. Did you not see that extra hammers get applied to the next unit?
Well, if the city is building heaviest military unit in 1 turn, there isn't any benefit from getting those extra hammer to next unit
An exampel to my theory:
At quick speed: City A has 70 production (with Heroic Epic). Heaviest military unit costs 50 hammers, so it takes 1 turn for each unit.
At marathon speed: Here, the timer is set like x4 of quick speed, so the military unit costs 200 hammers, still with 70 production. So it takes 3 turns to finish the first military unit but 10 hammers get carried on the next unit. So all in all, no hammers are wasted.