Any railroad corporation that violates any of the provisions of this chapter is liable to the state in a penalty of not less than five hundred dollars ($500) nor more than five thousand dollars ($5,000) for each offense. The penalty shall be recovered and suit therefor shall be brought in the name of the state in a court of competent jurisdiction in any county into or through which said railroad may pass. The suit may be brought either by the Attorney General of the state or under his or her direction by the district attorney of any county in the state into or through which said railroad passes.