How do websites offer a factory unlocking service There are numerous websites online which offer an actual genuine factory unlocking service if you provide the iPhone's IMEI code. They advertise a service which whitelists your iPhone's IMEI code from Apple's database. As far as I know, only certified carriers can carry out this service.

How do these independent websites and other individuals manage to offer this service too? According to user comments and testimonials they really do carry out what is advertised.
They pay someone that works for a carrier to enter that information into the carrier database or they have hacked access to that database. 

As long as iTunes gets the device ID as one to be unlocked when it restores the device, it gets unlocked. Otherwise it gets locked to the carrier under which it was sold.