Factory unlocked means the iPhone is legitimately unlocked in the Apple data base. Non-factory unlocked means iPhone is unlocked using hacking technique such as jailbreak or by use of simcard. Non-factory unlocks are less stable, may void warranty and will be lost or not work after upgrading the ios firmware.

A locked iPhone means you can only use SIM card from the carrier the phone is locked to. For example a locked iPhone purchased from AT&T would not work with SIM card from any other phone carriers. An unlocked iPhone has no such restriction.

Riding on the huge demand of unlocking iPhone, there have been many scammers claiming to be able to software unlock iPhone with a fee. There has been no known success software unlock since 2010 and these claims are simply fake and if paid will be money down the drain. However there has been report of successful IMEI unlock (unlock by modifying phone company's central IMEI database), be ware of this as many services advertised on internet are scams.

Jailbreaking allows users to install any software on iPhone, unlocking allows users to use SIM card from any carrier on iPhone. For iPhones that are not factory unlocked, jailbreaking the iPhone is necessary before the unlocking software can be installed to unlock the iPhone.

in US, your iPhone 4 will be locked to AT&T.In Canada, if you buy your iPhone 4 through a phone carrier, your phone would be locked to that carrier. If you buy your iPhone 4 from Apple Store, your phone would be unlocked.(this is an incomplete list)

Here are some options, starting from the one that's most likely to be successful:

Official Carrier Unlock: Some carriers offer the option to factory unlock your iPhone once your contract expires, sometimes for a fee. Not all carriers offer such option. If you are still on contract, chances are the carrier won't unlock your phone. If you are out of contract, contact your carrier to see if your phone can be unlocked.

IMEI Unlock: Because iPhone check with central IMEI (device ID) database to see if it should be locked or not, someone with access to IMEI database can modify the database to unlock your phone. This is not legal but works like factory unlocked when it does work. Be ware that a large number of services advertised on the internet are scam and will not work, make sure you go to a reputable service.

Hardware Unlock: the most well known hardware unlock option is by a company called GEVEY. One need to order a physical sim card tray from them and follow a complicated process to unlock phone. Many hackers don't suggest this option as it requires one to dial emergency number (such as 911) to activate, which is illegal.

Software Unlock: once the most popular option, but since 2010 after Apple patched up the latest exploits, there has been no known successful software unlock. If you are the rare few who hasn't update firmware since 2010, you may check out the most popular software unlock tool "ultrasn0w".

Downgrading firmware on iPhone is near impossible without a key called SHSH blob. If you don't know what it is chances are you don't have it. It's Apple's mechanism to prevent users from downgrading their firmware. Expert users who wish to upgrade while keeping the option to downgrade in the future make a backup copy of SHSH blob before upgrading. Moreover, unlocking depends on baseband version not just firmware version.

The ability to unlock by software is determined by the baseband version (which is different from the firmware version). In order to use the unlock tool ultrasn0w, baseband version needs to be 4.26.08, 5.11.07, 5.12.01, 5.13.04 or 6.15.00 for 3G or 3GS, and 1.59.00 for iPhone 4 (would be the case only for earlier version of iPhone 4). iPhone 4S is not unlockable.