Yes ATT phones sold at the apple store are locked to ATT.
However if you pay full price, then that information is submitted to AT&T and they tell Apple that the phone is eligible for unlock and the phone's IMEI is added to the list of unlockable iphones on apple's servers.
Thus when you activate your iPhone with any sim card, the activation server sees the phone can be unlocked and will unlock it. AT&T is really good about this.
Tmobile, even if you pay full price from a tmobile store, you have to wait 40 days before they unlock it...jerks.
Tmobile iPhones from The Apple store are all factory unlocked. Even if any genius or specialist tells you it's not, it is (and has been confirmed 500000x on this forum)