If the wrong unlock code is entered six (?) times, the phone hard locks and according to Moto and AT&T, that's "forever". Supposedly this changes something in the phone and no one, not even Motorola, can re-program the phone to unlock the carrier subsidy lock after it has been hard locked.
So if you had someone screwing around with your phone and the code AT&T gave you does not work, that's probably the answer. I had the same problem with an at&t refurbished phone, apparently the previous owner blew the hard lock and that locked it forever.
You can still use a locked phone with AT&T MVNO's like Red Pocket, H2O, or Simple (Simply?) Wireless but not with T-Mobile. Which is not a total loss since only AT&T MVNOs will be able to get full data service on an AT&T phone anyhow.