A water heater nearing the end of its service life is usually replaced rather than repaired once the tank itself starts to show rust at a seam or the cost of repeated repairs starts to approach a new unit. The old tank is drained and disconnected, and the new one is set, connected, and tested before the visit ends.
A straight swap in the same location is the simplest version of this job. Relocating a unit, changing from tank to tankless, or rerouting supply and venting lines to fit a different spot takes more planning, and that planning happens before the old unit ever comes out, not during.
Either way, the replacement is tested under full water pressure and a normal heating cycle before anyone calls the job finished, and the old unit is hauled away rather than left behind for the homeowner to deal with.