Can I buy any iPhone and have it unlocked for T-mobile?

I'm planning on buying the Iphone 4 or 4s and I was wondering if I can buy an AT&T or Verizon Iphone for cheaper and have it unlocked?
Most iPhone's that are unlocked go for an average of $170-250. Verizon or At&t iPhone's go for $100-140.

So what do you think?

Yes, when you Unlock a phone from a carrier you can use any other network (except if the phone is restricted to GSM/CDMA). So if you unlock an iPhone from AT&T you can use it on T-Mobile.

Recently the US government approved to make Unlocking legal so you can now do it easily.

However Unlocked phones might vary in their network technology, some are GSM based some are CDMA. I'm not from US so I don't know which carrier uses which but after you unlock then please verify about if it can run on these networks. It might work on both too.

If you get an unlocked iPhone it will work on any network.

You can get the Verizon or AT&T iPhone 4S and get them unlocked and it will be cheaper. If you need help with getting an iPhone 4S at much cheaper price, mail me.

IPhone 4 - yes, only if you buy the GSM model. The CDMA model will only work on CDMA carriers (Sprint/Verizon)

iPhone 4s - yes. It is a GSM/CDMA phone.

If those are the prices you are seeing for unlocked phones, I'd just buy the unlocked ones from the start. Unlocking an iPhone could cost between $30-170 depending on the guarantee rate/time you want to wait