States and cities are loosening building code requirements in an effort to lower construction costs and boost affordable housing.