When someone purchases a cell phone from his wireless provider, the phone is almost always considered to be locked. This means that it only works on the wireless provider's network. An unlocked cell phone works on any network.
A lock is really just a code written into the phone's software. The network companies purchase phones from the manufacturers with their own codes installed in the software to make sure the devices cannot be activated on their competitors' networks. This is a tactic used by the wireless companies to dissuade people from switching networks too frequently. Since the phone cannot be used with the newer provider, regardless of much the customer likes his phone, he would have to buy it again through his new wireless provider if he were to switch networks.
Certain phones can be purchased as unlocked, which means they do not have the wireless network provider's code in the software when sold; however, not all phone models have this option. Unlocked phones can also be found for sale at sites such as eBay. However, anyone who uses an unlocked phone is likely to find that the provider is less likely to help solve any problems with the phone since it is not owned by the network.