This isn't a law, it was a voluntary agreement between the carriers to make all phones they (the carriers) sell have a permanent shutter sound. This was done to stop the moral panic due to "upskirting" on subways/etc.
Since Apple sold iPhones only through carriers initially, they complied with this agreement.
A better example of this would be Apple disabling FaceTime on phones sold in the UAE, which is the result of a law, and the feature stays disabled even if the region is changed from/the phone is removed from the UAE.