Exactly. The odometer is either mechanical or electronic and neither is tied to the engine itself. Mileage on a real car is related to the body, or at least the instrument cluster (for those shady guys).
Rebuilding an engine doesn't mean it's a complete replacement also. The engine block might still be the same, so technically still keep the mileage but with restored HP.