Ooh tricky question, I like those! Let me simplify the question a bit because I think it will become much more clear where the difference is.
Simplified proxy question:
Imagine you have lifted a bucket of water from the ground up to waist height. You now have the option of pouring the water out of the bucket onto the ground, or, pouring the bucket onto a water wheel which will turn and generate electricity. In one case, you get nothing from pouring the water on the ground, and in the second case, you get useful electricity. How is pouring water onto the water wheel better than pouring water onto the ground?
The answer to the simplified question is that when you pour water onto the ground, the water strikes the ground with a high velocity and generates heat due to the inelastic collision with the ground and the friction (viscosity) of the water. When you pour water onto the water wheel, the wheel slows the water down and extracts the potential energy from it so that when the water finally reaches the ground it has much less energy to give up.
So, pouring the water on the ground wastefully release all the energy at once when it hits the ground. Pouring it on the water wheel extracts some useful energy from it reducing the amount wasted on the ground. The total amount of energy spent by your body and the total amount of energy released is the same in both cases.
Your exercise question is just a slightly more complicated version of this. If you setup the exercise with weights versus exorcise with a generator so that the workout to your body is the same, then you will be able to find where the energy with the weights is being released as waste.