When they (apple) replace your phone, they transfer your phone status (locked/unlocked) to the replacement one.
I can speak of that based on my own experience and information from apple discussions forum.
I can speak on that based that i used to work for the Apple store at the Eatons Center. All of them are unlocked until they activate the sim card / put the sim card in. Once they do, it will lock to that carrier. That is why they just grab any phone from the drawer.
Even when they scan the S/N number, i will register that S/N to your name / email account for future warranty. The only way it will lock to the carrier is when adding the sim card in & activate it. Now if they changed it within the last year & i am not aware then i need to see it but as i know it, that is the way.
Edit - Called my buddy which works for the Apple store at Yorkdale & another one at Eatons center. They both confirmed that they lock the device via the sim card when its inserted. All the iPhone's in the drawer that they bring out are unlocked until the sim card is inserted. Once the sim card is in the phone, it will lock to that carrier.
NOW if you have a factory unlocked iPhone & you go exchange it, they will give you a factory unlocked iPhone from another drawer. This is how it was when i was working there & when i just called to confirm.
Great that you had detail insights. I have no doubt that you are right on the issues of how apple store work.
However, I think you answered the question from a person who worked within the process of exchange not from customer viewpoints.
Normal customers will not have access to the drawers inside apple store and have no choice of picking locked/unlocked ones. They come to store and come back with the replacement phones that have the same original status. I think that is a "correct" answer.
As a reminder, ALL iPhones are REFURBISHED when replaced by Apple unless it's a brand new model that just came out. For example, in September the iPhone 6 will be out.
Should you have any issues with the iPhone 6 that you receieved and it needs to be replaced, Apple will give you a brand iPhone 6 as they do not carry refurbs since the device is so new. In general, you can expect a new device as a replacement within a few months of the new product being available.
Additionally, when you meet up with the Apple "Genius" technician, ensure they notate on your profile and workorder that your device is unlocked. When you get your replacement device, ensure it is also unlocked by reminding the tecnhician to insert a different SIM into your device.
As another caveat, those who are thinking of unlocking their device so it can work in Roam Mobility, be aware that LTE will NOT work on the iPhone 5, 5C and 5S. Roam Mobility quickly is shrugging all responsibility onto Apple while users who buy a T-Mobile Pre Paid SIM and plan have no issue with their iPhones (presuming it can run on their network). . It's just Roam Mobility is intentionally misleading consumers into jumping onto their network when there are other better (and convenient) options available.