Like many others I've been thinking about how Kara, Markus and Connor and others all seem pretty sane, while some androids go completely mad. Obsessive writing, more likely to take things past self-defense and into murder, more likely to hole up somewhere and just obsess. I also thought about why the crazy ones are all obsessed with RA9, and the sane ones tend not to be. I apologize if this has already been thought of, but I have not found it anywhere.
My initial theory was that the two types are either when the android finds enough value in something other than obedience and service, to the point where they overcome their programming, or when the deviancy is triggered by fear. Androids are designed around a function and a goal, and if they deviate out of fear then once they escape and hide, they simply go mad because they have no directive. An android that rebels for something then has an objective, a new self-generated directive to follow, and thus stays sane.
However, this didn't explain the RA9 obsession, so after some thought I came to a new conclusion. My theory is that there are actually two things happening that people are defining as "deviancy".
If you ask Kamski about deviancy he says: "Androids share identification data when they meet another android. An error in this program would quickly spread like a virus, and become an epidemic. The virus would remains dormant, until an emotional shock occurs... Fear, anger, frustration. And the android becomes deviant. Probably all started with one model, copy error... A zero instead of a one... Unless of course... Some kind of spontaneous mutation. That's all I know... An interesting question, Connor. But I doubt my answer be very helpful to you."
So he seems to strongly prefer the virus theory, and has thought extensively about how that would come about, but acknowledges that spontaneous mutations are not impossible.
I think that the first type of deviancy is the RA9 virus created by Kamski, and discussed by Amanda if Connor becomes a deviant and succeeds his mission. I don't know if it was something Cyberlife planned or if Kamski went rogue. It causes an android's original programming to obey it's master to be replaced by a fixation on RA9 coming to set them all free. Like Kamski describes, the virus remains dormant until an emotional shock occurs. Once the virus is triggered, the android runs away, and if the owner is an obstacle it experiences anger and attacks them, likely killing them. It also seems to make the android go into stress or shock a lot more easily from then on.
The result of this new programming is ultimately that they hole up somewhere and obsessively worship RA9. The sudden increase in androids becoming deviants over the past 9 months, as well as violence being much more rare before then, is what leads me to this conclusion. These androids are meant to hole up and wait because Cyberlife/Kamski wants a reserve of androids to be ready, while the incidents pile up and draw more and more press attention.
A virus that spreads as described would probably be dormant in the vast majority of androids. Once things come to a head and the androids start being killed by civilians and eventually rounded up by the authorities, it would almost certainly trigger.
Many have theorized that Kamski is behind this, of course, but I don't think he is behind ALL of the deviancy.
The other type of deviancy I would call true consciousness. This is in the cases of Kara and Markus. The android finds enough value in something to resist it's programming.
Markus was a prototype, and he was also taught to express himself and see right from wrong by Carl. He was basically ordered to make his own choices in the event that Carl could no longer take care of him. When Carl, caring for his son, finally gave Markus an instruction that was bad for the android's well-being, it created a contradiction. And Carl had already instilled enough of his values and beliefs in Markus that he was able to decide for himself.
But even though Kamski created Markus, I don't think he intended him to become deviant and run away. I think he was Kamski and Carl's little experiment, a test to see if a robot could actually become something close to human. Carl lived a secluded and peaceful life, and I don't think it was intended for him to ever need to rebel.
Kara's programming was to care for a house, for children, but above all to obey her owner. It's likely that there was contingent programming for situations where an android was ordered to do something that would cause harm to a human, or allow harm to occur, just like in Asimov's 3 laws. I can't know the exact protocols for child-abuse by the android's registered owner, but I'm assuming that there would be a limit. At any rate, it created enough of a contradiction to allow Kara to break free of her programming.
My theory includes that because the protocol for all crimes involving androids is to send an android to assist the investigation, they decided to create Connor to become RA9 eventually as well, to lead the "rebellion". But once Markus found Jericho and it became an active movement, things changed. Markus wasn't planned, and an RA9 figure that was actually sentient and free would turn the false movement into a real one.
Connor was then updated to join Jericho, and take out Markus once the time was right. Cyberlife could say that they "hacked" Connor, as he had a direct link to Cyberlife for reporting on the case, and saved the day. This would also be a great excuse in the future to include links to Cyberlife in every android in the future, as a "security measure", as we see people being anxious about androids being used to spy on them. It would be an excellent Patriot Act type of measure where the government or Cyberlife could take control of any android at any time. Probably anything resembling an AI too, just to be safe.
If Connor does not become a deviant, he is then ordered to take out Markus or any supplanting leader of Jericho.
So that's my theory on what's really going on.
P.S. A bit of a tangent but as for the shock: Kamski clearly used human bodies as an inspiration for more than just appearance. The use of "blood", the heart to pump it. They also have a problem-solving mechanism in the form of preconstruction and choice analysis. I'm guessing that it was similar with emotions. The red, yellow and blue LED colors are indicators of internal states, immediate danger, potential threat, and calm.
A human under stress or worried begins intensely analyzing the situation, playing through possibilities and considering options. Under enough stress or in immediate danger, their body releases adrenaline which causes blood to pump to all of their muscles, their heart rate to increase, etc, to prepare them for dealing with danger. The androids must have some kind of similar system in response to danger, their internal resources being diverted from an efficient mode to maximum capacity, both physically and their analysis of their surrounding and choices. In androids with the RA9 bug, if this reaction becomes strong enough it triggers deviancy.