If you buy an unlocked iPhone, you can only use it on AT&T or T-Mobile. You cannot use it on Sprint or Verizon because they are CDMA technology, which means they don't use any sort of sim card for phones. All the data is stored on the phone itself.
With AT&T and T-mobile, they are GSM technology meaning they use sim card for all their phones. In the case of the iPhone 4 and 4S, you will need a micro-sim card. All the data will be stored on the sim card, although you can backup your contacts via iCloud, your computer or the sim card.