iPhone 3G and iPhone 3GS are sold LOCKED to AT&T's network in the United States.
iPad 3G is sold UNLOCKED.
iPhone 3G, iPhone 3GS, and iPad 3G all have the same baseband chip, X-Gold 608.
The iPad's baseband chip is unlocked permanently, the iPhones' baseband chips are locked.
So... Now it's starting to make sense, right? Yeah, just swap them out. It's that simple! Although doing this will void your warranty for good.
Let's go over this. That baseband chip in the iPhones are locked to AT&T. You're carrier is T-Mobile for example. The iPad 3G baseband chip is unlocked, but you use AT&T's no contract plan on that. So if you swap them out, everything will work since you're using your iPad on AT&T with an AT&T carrier-locked baseband. And you're using your phone with an unofficial carrier, but is supported because of the unlocked baseband.
You can refer to this article below for reference.
http://theiphonewiki.com/wiki/index.php?title=X-Gold_608