I don’t know about those you bought from att, so just speaking for Apple situation.
The thing is, all iPhone comes out unlocked, if you use your contract or carrier stuff to buy the iPhone, Apple just wont send any information to carrier therefore the carrier won’t have anything to lock you in. If you use your carrier info when buying from Apple, then Apple will tell the carrier “hey, this guy bought this iPhone with serial and IMEI number xxx on your network, so go ahead and lock it”.
So in short, if you just walk into an Apple store and buy it outright, it’s unlocked.