Here are the details. You would need to check with TMobile whether the particular plan you are on is compatible with using the Apple Upgrade Program since some carriers have plans that are linked specifically to device purchases through its own channels.
When you purchase or get a phone with a plan. It's like buying a car. It's not fully yours until it's paid off. Most Carrier phone plans is usually 30 months, sometime they will allow you to upgrade at 24 months, but you will be paying an extra to finance the phone. So to take advantage of Apple's upgrade plan they will give you credit for your phone, assuming it's paid off, towards the purchase of a new phone. No financing, no Carrier Lock, no Contracts or commitment. So if you like switching carriers, it's great.
Question: how does iphone upgrade program work