Mental disorders, which are fundamentally undesirable phenomena, can be both environmentally and innately caused. There are both neurological components as well as environmental components almost exclusively sourcing from childhood.
In the same way, a "thinking machine" can have the same undesirable problems. I imagine the "neurological problems" would be tantamount to bugs in the original software and hardware malfunctions. Much more common would be the environmental causes, similarly in the AI's "childhood".
Human childhood is a very impressionable time. Love and proper care leads to healthy growth, proper perspectives of safety and danger, proper priorities leading to healthy adult human lives. Abuse and neglect lead to psychological malformations such as unhealthy concepts of danger, of self, of the meaning of love and family, etc.
Similarly, AI "childhood" will be the beginning period of discovery and learning (which may happen in R&D labs, rather than the real world, depending on the circumstances). While it's difficult to say what might cause malformations, it's safe to assume that improper training of the AI, just like improper raising of a human child, will result in odd, unpredictable, and undesired behavior.
As a note, this is all technically true for AI less sophisticated than "thinking", but the simpler it is, the easier it is to properly train and prevent hardware and fundamental software errors. For example, an AI that identifies pictures would show unpredictable and undesirable behavior if, for some reason, it was trained randomly (say, by using crowd-sourced training and being the victim of trolling). A 'thinking' AI would likewise have undesirable results if it were "abused" or never taught the value of, say, life. One, in that case, might easily end up with a "sociopathic" AI.