Carfax uses government records from those states that can provide them electronically at a reasonable cost. They don't get data from insurance companies or even local police reports. If your state has a state-level database for accidents that's electronic, then Carfax might get data from there.
In Illinois, the Secretary of State handles drivers licenses, plates, and titles, but the Ill. Dept. of Transportation (IDOT) tracks accidents because they're the ones who use that data for improved road engineering. I know the Sec. of State data gets to Carfax, but IDOT loves their paper, and therefore I don't believe Carfax gets accident records from IDOT. If the car is damaged bad enough to get a dirty title, then Carfax would get that info from the Sec. of State.