The governing body of every municipality shall have plenary power and authority to provide for the prevention and extinguishment of fires, and, for this purpose, it may, among other things, regulate how buildings shall be constructed, procure proper engines and implements, provide for the organization, equipment and government of volunteer fire companies or of a paid fire department, prescribe the powers and duties of such companies or department and of the several officers, provide for the appointment of officers to have command of fire fighting, prescribe what their powers and duties shall be, and impose on those who fail or refuse to obey any lawful command of such officers any penalty which the governing body is authorized by law to impose for the violation of an ordinance. It may give authority to any such officer or officers to direct the pulling down or destroying of any fence, house, building or other thing, if deemed necessary to prevent the spreading of a fire.