He made an agreement with a DA not to be prosecuted if he testified in the civil case.
The next DA said eff that agreement, I’m prosecuting. The state Supreme Court said that violated Cosby’s due process.
That's basically what happened. Nothing to do with evidence, but a technicality.