And municipalities, counties, or states adopt the NEC as law. Most areas of the country have done this. That's where it gets it's authority. But it may have no authority where you are, depends on whether it was adopted or not.

Lots of organizations write "model" codes for electrical, fire protection, heating, structural, etc, etc. and they make these available to governments to adopt as law.