Building codes are specific laws to tell builders what the minimum requirements are when constructing a building. The laws are made for safety reasons and to protect the general public. Most of the various building codes are designed to be followed by architects and engineers who are actually designing buildings however they are also building codes that apply to contractors, manufacturers and insurance companies.
Almost all building codes are designed at the state and local levels and they all vary, however all are fairly similar. For example the NY building codes might require that electrical outlets be spaced no more that 10 feet apart while NC building codes may require that they be placed no more than 12 feet apart. While many of the differences may seem trivial, it is important for the states to have separate building codes to take account for things such as the regional environmental conditions.
For example, the NC building codes are different than the Alaskan building codes because North Carolina has a temperate environment while Alaska has frigid conditions that put different strains on buildings. NC building codes take into consideration tropical storms and hurricanes which might come out of the Atlantic Ocean. North Carolina building codes might also take into account such things as local insects which may be a hazard to certain types of building materials.
Some states may also decide to be more progressive with their building codes than other states. For example, the NC building code may not be as friendly to the environment as the California building code, a state well known for placing environmental concerns at the forefront. States must decide for themselves how to strike a balance with deciding how much to require of the builders. By requiring builders to do more they drive up the price of construction which can put a strain on the economy statewide.