When switching carriers with a T-Mobile phone, you need to make sure your device is unlocked and you have no outstanding fees on your device. You also need to make sure you are switching to a carrier compatible with your GSM T-Mobile device.
Your AT&T phone will only work with a selection of carriers so you need to check first before you commit to a new plan or switching carrier.
Use this link to check your devices compatibility. This compatibility checker will show you which carriers you can use your device with.
Remember that you can port your number to your new carrier - make sure that you don't disconnect or cancel service with T-Mobile until you've got your new plan set up with the new carrier (otherwise you may lose your number)
You can see all of the carriers that you can switch to here - BYO plans that work with an unlocked T-Mobile Phone
Sprint and Verizon run on CDMA technology, T-Mobile and AT&T operate on GSM - as a general rule, you won't be able to use your GSM phone on a CDMA network (some new iPhone 6s and Nexus phones may however work but you need to check)