AT&T doesn't allow people to use iPhones on their network without the appropriate data plan if you buy the iPhone through either them or Apple. That being said, let's get some more info.
First, right now the ONLY way to currently get an iPhone 3GS though AT&T is by buying the phone from Apple or AT&T and signing up for the two-year contract. Then, you can cancel the contract and pay the cancellation fee. I'm not sure what the cancellation fee is off the top of my head, but I think it's currently a couple hundred bucks. Once you do that, you'd be free to do whatever you want with the phone.
Since there is currently no jailbreak or unlock compatible with the 3GS, you'd essentially have a paperweight at that point. I'm 100% sure they're currently working on it, but no guarantee on an ETA.
Now if you pick up an unlocked iPhone or iPhone 3G and you're just planning to use the iPhone as a phone, then you should be okay, you just won't be able to get Edge or 3G (if applicable) access through the iPhone. The only way to use the internet stuff would be through Wi-Fi, and you should be able to get away with it. Why? Because if you don't have a data plan anyway, you won't be able to send and receive data over the phone via AT&T's wireless network so I don't think AT&T can tell, but you can still access internet, email, etc via Wi-Fi hot spots.
But, IF you have a data plan though AT&T and you start using an iPhone on that plan, they yea, I think they can detect that and will put you on the iPhone plan automatically. I'm not 100% sure about this part, but you should be able to use an unlocked iphone on the AT&T network as a regular phone without all of the data and stuff. You're just not going to be Edge or 3G (if you have an iPhone 3G).
As far as T-Mobile, if you have an unlocked iPhone or iPhone 3G and have the T-Mobile data plan, you can use Edge all day long with the iPhone or iPhone 3G. But you can't get an actual 3G signal because T-Mobile's network architecture is different and isn't compatible with the iPhone 3G. Same would go for the 3GS.
Hope that helps.