While I mostly just buy my phones unlocked from Apple directly, I *somewhat* understand and sympathize with the carriers. They want to win over post-paid customers (as the majority tend to be relatively sticky), and to get them to switch, they offer them big discounted deals on the devices.
As part of that deal giving, they want to be able to ensure that these new subscribers that get a discounted phone, stay with them long enough that the "loss-leader" discount was worth it.
The way I understand it works: most US carriers make the discount (let's say they advertise a "free iPhone 16" which has a $800 MSRP), what they really do is give you $800 in "monthly device credits" over let's say 12 or 24 months (so $67/month or $33/month). So you don't pay anything up front, but you technically "owe" the carrier whatever the remaining device balance is, which reduces every month you stay with the carrier. So if you were to take the deal, but then leave after 3 months with the phone, assuming it was a 12month credit, you'd still have $800 - $99 = $701 owed, and thus you'd have to pay that out to keep the phone and get it unlocked. If it was already unlocked, the "fraud" is that the subscriber just keeps the phone, and tells the carrier to go pound sand for the amount owed. If it's a real person, they get a hit to their credit perhaps. But this is where potential fraudsters (maybe with fake or stolen SSNs) don't care and now have gotten a nearly free (and now unlocked) iPhone they can sell and make a tidy profit.
As a customer, would I prefer to get the discount, AND keep it unlocked? Of course. But I also like the option of getting these highly discounted phones from carriers as an incentive to switch. And I *understand*, given the way that scammers have taken advantage, why carriers use the locking to try to keep this from happening. For most people who would get the discounted phone, it wouldn't matter as they'd stay long enough with the carrier to have it unlocked automatically. Or if they do leave carriers for legitimate purposes, would understand why they need to pay off the remaining device balance, and could then get it unlocked if they want to.
If carriers couldn't do this locking, then realistically, they'll be forced to reduce the amount of device discounts they give to entice new subscribers. And then the "honest" folk (the vast majority who aren't affected by the lock) get worse deals.
I do get the potential inconvenience of not being able to get a separate SIM when traveling if your phone is still locked. However, I do think this is an edge case. For most of the big carriers, they have reasonable enough pricing for international roaming, that it's really only those who are traveling internationally for long periods of time, where the inability to get a local SIM really hurts.... So if you are in that edge case where it matters, definitely makes sense to just buy the phone outright / unlocked from Apple.