There are cases other than what you mentioned where the carrier refuses to unlock. During 2021, AT&T forced a phase out of 3G and provided allowed customers to get a free upgrade phone in the process. As a prepay customer, I took the phone but jumped ship to a different carrier. I tried to get them to unlock the phone earlier this year and they refused. There was no contract/lease involved, but they didn’t like that I didn’t remain a customer with them for (I think it was) 180 days after that.
There are cases other than what you mentioned where the carrier refuses to unlock. During 2021, AT&T forced a phase out of 3G and provided allowed customers to get a free upgrade phone in the process. As a prepay customer, I took the phone but jumped ship to a different carrier. I tried to get them to unlock the phone earlier this year and they refused. There was no contract/lease involved, but they didn’t like that I didn’t remain a customer with them for (I think it was) 180 days after that.