maggie.. there are two different things you should know..
jailbreaking - is the term given to the process of breaking the "jail" apple has put the iphone in and allowing you full access to the unix file system as well as loading non-apple approved software.
unlocking - is the process of breaking the carrier restriction on the device and allowing you to use it with any cellular carrier. so you could take your iphone and use it with a carrier other than AT&T who uses the same radio technology (t-mobile in the US.. but not
sprint). generally unlocking requires you to first jailbreak the iOS device.
if your 3G comes off contract and you upgrade to a 4G you are not required to keep that 3G on AT&T. however at this time apple is not unlocking your phone so you can take it to another carrier either. you could, however, jailbreak the phone and then run unlocking software on it and use it with any carrier. you could give it to a family member who uses t-mobile and they could use it with their SIM card. note, not all features may work properly (visual voicemail doesn't work for example) or might require some additional configuration to get SMS/MMS to work.
also, do not
buy any software to jailbreak and/or unlock your phone. the development community (http://blog.iphone-dev.org/
) that works hard to bring us these capabilities do not charge for their services. however there are many shady individuals out there who take their hard efforts, package them up in a pretty bow, and try to sell them for all sorts of amounts. you never know what else the could include in their software. only download jailbreak software and unlocking software from their "official" sources.
apple does sell some unlocked phones in various countries, generally for a more expensive price. you can now get an unlocked 3gs or 4 in canada for ~$750USD. you could drive up, purchase a phone, bring it back to the US and use it on AT&T or t-mobile without a problem, even going between the two carriers over and over by swapping sims.