iPhone Jailbreaking and Unlocking
Jailbreaking is the process of hacking the code signing mechanism to allow unsigned code to run on the phone. There are multiple tools used for this and they vary between both model and iOS version.

Unlocking is the process of hacking the 3G chip's baseband to allow SIM cards from other networks without an official unlock from the carrier. There's also an alternative method called Subscriber Artificial Module (SAM) which creates a fake but slightly more authentic unlock from iTunes. I have never needed a hacked unlock (Australia has official carrier unlocks) so I don't know much more about it. Unlocking naturally needs a jailbreak to work, which is why the two are sometimes confused.

If you want a more technical answer you'll need to specify one or the other, as jailbreaking and unlocking are two entirely different types of hacks.

I'd also advise against trying anything you don't completely understand because if you don't know what you're doing you're liable to make irreversible changes to your phone, especially when tampering with the baseband.