GSM phones can be "locked", that is made to accept only SIM cards belonging to a specific network. Typically, this is done so that phones will work only on the network of the carrier.
SIM-locked phones are usually locked to a carrier when the carrier sells the device at a subsidized price in order to attract new subscribers to its services.
Some carriers offer a SIM unlock option to their subscribers after a certain amount of time has passed. Unlocking the phone can be done by entering a special code which is generated based on the phone's unique IMEI number.
Some third-party shops offer unauthorized unlocking of SIM-locked phones, but using their services usually voids the official warranty of the phone.