Yes, you can. Make sure the seller is a reputable seller before purchasing a device (there's people who have bought devices from a not-so-reputable seller and they get reported stolen and blocked).
If it's the same size SIM, just pull out the SIM from the old phone and put it in the new phone. If the SIM is a different size, you'll have to buy a new SIM and contact T-Mobile to modify the SIM associated with your account. http://www.t-mobile.com/SIM should work to update your SIM if you're a postpaid customer.
The SIM should be all you need to activate. Which is super handy if you like to swap between devices. Just move the SIM and BAM! you're good.
Manage your T-Mobile account