The battery is charged by plugging it into the wall, and the more you pedal the farther you can go. Your pedalling conserves the battery, but it doesn’t actually charge it.
The technology does exist that would allow you to charge your bike by pedalling, but we’ve found that it just doesn’t make sense in the real world. The benefit is very little, it makes the bike even heavier and it increases the overall costs.
The problem is that it makes it hard to pedal, and that’s not fun! Even under the most ideal conditions, like riding downhill, the amount of energy you would get back is negligible.
Pedal assist is wonderful for long rides with few stops on relatively flat ground, because you can just relax and enjoy the ride without holding a throttle in place. It’s like cruise control.