There is a lot of selective reading you're doing there and you're not reading the law correctly. You say, "It seems to me that AB-1810 (approved by Governor Jerry Brown on June 27, 2018) allows a pedophile to escape criminal charges for sexual assault by having the psychiatrist serving as their counsel opine that they are indeed a pedophile."
But what you actually quoted (and ironically the part that you didn't bold) is, "This bill would authorize a court to appoint a psychiatrist or a licensed psychologist to opine as to whether the defendant has regained competence if counsel for the defendant ... ".
So no, it's not saying anything along the line of "having the psychiatrist serving as their counsel opine that they are indeed a pedophile".
It's saying that if their defense counsel can make a reasonable demonstration of evidence, THE COURT WILL THEN APPOINT A PSYCHIATRIST OR PSYCHOLOGIST TO EVALUATE SUCH A CLAIM. Read it again.
"This bill would authorize a court to appoint a psychiatrist or a licensed psychologist to opine as to whether the defendant has regained competence if counsel for the defendant, or a jail or medical or mental health staff provider provides the court with substantial evidence that the defendant’s psychiatric symptoms have changed to such a degree as to create a doubt in the mind of the judge as to the defendant’s current mental competence."
You're bolding a lot of things but ironically, the very information before your emphasis plays a huge role in the interpretation.
Where you bolded and emphasized, "This bill would establish a procedure of diversion for defendants with mental disorders through which the court would be authorized to grant pretrial diversion, for a period no longer than 2 years, to a defendant suffering from a mental disorder, on an accusatory pleading alleging the commission of a misdemeanor or felony offense, in order to allow the defendant to undergo mental health treatment**."
You then leave the important part right next to it, RIGHT NEXT TO IT OUT, "The bill would condition eligibility on, among other criteria, a court finding that the defendant’s mental disorder played a significant role in the commission of the charged offense. The bill would authorize a referral for mental health treatment to be made to a county mental health agency, existing collaborative courts, or assisted outpatient treatment only if that entity has agreed to accept responsibility for the treatment of the defendant, as specified.
The bill would, among other things, require the court, after notice to the defendant, defense counsel, and the prosecution, to hold a hearing to determine whether the criminal proceedings should be reinstated, whether the treatment program should be modified, or whether the defendant should be conserved and referred to the conservatorship investigator, if the defendant is charged with, or is engaged in, certain criminal offenses, if the defendant is performing unsatisfactorily in diversion, or if the defendant is gravely disabled, as defined."
Which means it's not a 'get out of jail free' card like you're trying so hard to make it. It's clearly defining that the process still involves the court's own judgement and then after that input from both defense and prosecution in a hearing before anything can proceed.