It depends on the brand. Some are locked to a single provider, though they usually have a range of plans so you can find something suitable in terms of cost and service. Some work on a variety of networks and technically are unlocked, but that doesn’t mean a particular carrier will necessarily provide service for them. This often changes, so you’ll need to investigate what’s possible at the time when;you buy your phone. You can usually keep your existing number, even if you change the carrier.