The district attorney shall defend all suits brought against the state in his or her county or against his or her county wherever brought, and prosecute all recognizances forfeited in the courts of record and, except as provided in Sections 1305 and 1306 of the Penal Code, prosecute all actions for the recovery of debts, fines, penalties, and forfeitures accruing to the state or his or her county.