To use your phone on any network, not just the phone seller's network, the SIM must be unlocked. Your phone may come SIM-locked or SIM-unlocked, depending on where you bought it.
You can switch carriers and keep your phone. Just put the new SIM card into the phone.
Some phones are SIM-locked by the mobile service provider/carrier that sold them. These phones can only get mobile service from the seller's network, unless the seller provides a subsidy unlock code to remove the SIM-lock.
To unlock your phone:
Turn on the phone. If you use a PIN, password, or pattern to lock your screen, enter it when prompted.
You will see the message “Contact service provider”.
If you aren't sure which network has locked the phone, or if you believe the phone shouldn't be locked on any network:
Find your IMEI number:
To learn how to insert or remove SIM cards: