That's because when you're paying your bill, you're paying off a debt that you already owe - and since cash is legal tender for all debts public and private, if a company refused your genuine offer to pay off the debt with legal tender, they might be interpreted as having effectively forfeited their right to collect the debt at all. (The US Supreme Court has had mixed positions on this issue in the past, but IIRC this is one of the positions they've taken.)
An up-front purchase, on the other hand, is different from a debt. You don't own the phone - and thus you haven't incurred any debt - until after the transaction is complete. If the store doesn't want to accept cash for the transaction, then they have every right to stop the purchase in its tracks and prevent you from taking ownership of the phone.
The legal analysis doesn't seem entirely correct. For one, since the purchase of an iPhone ties you (in AT&T's eyes) to a voice and data plan, purchasing it is not simply a matter of an offer to treat and the exchange of goods for appropriate payment, but is also an agreement to future service to be provided and agreed payment to be made in return. The one is inherent to the other, not least because at the subsidized price, the on-going contract represents partial payment for the device.
The question of what is, or isn't, legal tender does not impinge on any seller's right to accept or refuse any specific means of payment for just about any reason. AT&T (or indeed any entity) can refuse to do business with anyone, and while there are some circumstances where this could be interpreted as legally troublesome (such as refusing to sell to a person of a particular racial origin) there is no legal implication inherent in refusing to sell to someone who wishes to pay in cash.
Not that it makes much sense to me that AT&T refuse to accept cash for payment of an iPhone, unless they are perhaps concerned from a corporate standpoint to ensure they have a valid credit card on file from which they might recover an unpaid debt if the customer were to immediately renege on the contract.