It was for the lifetime of the contract. Once the device was paid off, you could unlock the device.
https://www.macrumors.com/2012/04/06/att-will-unlock-off-con...
I might be remembering wrong, but I think the original iPhone has some sort of technical constraints working on T-Mobile's network even if it was unlocked.