Can you buy an ipohone separately and have tmobile connect it for you?

Basically I want to buy a refurbished iPhone 4 or 5 and cuz I hate the aspect of having an iPod touch and a Samsung gravity cell, and want to be able to play music and do my txt and web all in one. Can I buy my IPhone somewhere else and bring it to tmobile to transfer my account over?

Yes you can

You CAN, under certain circumstances.

The phone must either be factory unlocked (never locked in the first place, purchased directly from Apple) or a T-Mobile or AT&T phone that has been unlocked by AT&T. I would try to go with one that was a T-Mobile phone, because there are sometimes issues with unlocked phones when there's a software update, etc.

You need to check the phone because if it has been reported lost or stolen, it will be useless. If the person is still under contract the phone can't be unlocked.