They have several reasons. A good percentage of the time they can entice people into signing another contract to get a “deal” on a phone. A new contract will never, ever save you money no matter how much they say it will.
They also want you to buy a phone from them with their bloatware. If you bring a phone that’s unlocked sometimes you can do things that they don’t like but are still perfectly legal.
They don’t have to continually update Android. A flagship phone from a carrier may get one, possibly two OS upgrades. A Google pixel bought from Google directly has three years guaranteed to get the latest Android. A Google pixel from say Verizon may not get an upgrade at all.
Another reason is that telecommunications have backbones with a life cycle of say five years. There is already a sunset on 3g so now they are trying hard to get everyone still rocking something like an iPhone 4 to a device that’s 4g capable.