Yes, as long as it is UNLOCKED by AT&T to be used on other networks.
AT&T phones work on the T-Mobile network for voice and 2G data, but any faster data speed (3G, 4G, 4G-LTE) will probably not be available because T-Mobile uses different frequencies.
If you have a five year old 2G phone, you'll never notice a difference. If you have a 4G phone, data speeds will drop as it goes to 2G.
You might want to check your model of phone with any T-Mobile shop.
You can use your own phone but it needs to be unlocked first. You can ask ATT to unlock it or go to smart phone unlocking services for a fee, either way.