The contract issue had more to do with how the phone interacted with the network. IIRC, AT&T was an exclusive provider because of the backend requirements (visual voicemail notification maybe?). I assume the contract was in part because they wanted to recoup those expenses.
Here’s a news article from the time that says that AT&T didn’t actually start subsidizing the phone until the 3G arrived.
https://usatoday30.usatoday.com/tech/wireless/phones/2008-07...
Also, the subsidy might have been from Apple, if anyone… Apple got a kickback of $10/month per iPhone user. They might have used that to keep the price lower, but that wasn’t from ATT’s side of the account until the 3G followup.