Range is battery energy divided by how fast you spend it. The battery half is easy — a 500 Wh pack holds 500 Wh. Everything interesting is in the other half.
How much of the work you do. The biggest lever by far, and the one most calculators ignore. In Eco the motor covers roughly a quarter of the effort; in Turbo it covers three quarters; on a throttle it covers all of it. That alone is a three-to-one swing in range on the same battery.
Speed, and then speed again. Air resistance rises with the cube of speed, so going from 20 to 30 km/h more than triples the drag power. This is why a 250 W European pedal-assist uses 3–6 Wh/km and a fat-tyre throttle bike at 32 km/h uses 15–20.
Weight and hills together. Weight barely matters on the flat and matters enormously uphill, because lifting mass is the one cost you cannot get back — you brake on the way down.
Cold. A lithium pack does not use more energy when cold, it holds less. At freezing you lose over 10% of capacity, and you get it back when it warms up.