It works because iphone 4 has a bottrom exploit that can be triggered through usb packets, so you can get very deep access to the phone and edit this stuff before it even boots.
That's why it only works for iphone 4, there are not bootrom exploits for newer iphones.