In Ireland you can buy unlocked, or get a discounted locked phone with a contract. However, after your initial contract runs out the carrier legally must unlock the phone. In practice, getting them to unlock the phone is a bit like getting the direct debit on your gym membership cancelled, but you get the idea.