Dragon Ball: In trying to build an evil android, Doctor Gero produced as many as eighteen, all of which turned good (or, at least, insufficiently evil), before he finally developed one that worked as he intended.
Android 16 was built to kill Goku following the Red Ribbon Army's defeat, but he turned out to be too gentle, and thus was a failure. Interestingly, this particular crapshoot was Gero's own doing — 16 was based off of his deceased son, and Gero deliberately gave him this so that he wouldn't risk being destroyed in battle, despite his incredible strength.
Androids 17 and 18 are actually cyborgs, thus "A.I." isn't exactly applicable to them. Nonetheless, despite programming them with the same order to kill Goku, they rebelled against him and were switched off. Even attempts to fix this proved futile, as the next time they were turned on, Gero paid the price.
Hell, it's implied that Gero's latest androids (17-20) were all made either from human bases or as energy absorbing types because he couldn't make an artificial one out of perpetual energy that wouldn't do a Heel–Face Turn. Word of God even suggests the difficulty of "personality control" was the reason for why he started to modify humans who were already bad as opposed to building Androids from scratch.
All that said, he did make a few aversions:
Android 19 was the first Android Gero made that remained destructive, evil, and loyal in equal measures. Gero himself remained a bastard once he became Android 20.
It's unknown how loyal Cell would have been had Gero still been alive by the time of his awakening, but he seems loyal to Gero's vision of himself and his purpose — a being of perfection that, as it happens, was made to kill Goku. That is, until a certain near-death experience drives him to creatively reinterpret his purpose as proving his perfection by annihilating everything else — even then, he frames it as Gero's true intentions all along. In the non-canon anime filler and Dragon Ball GT, Cell actually does remain allied to his creator in the afterlife.
Dr. Slump, by the same author as Dragon Ball (and written before it), has the Caramel Man robots, though not all of them have A.I. Caramel Man 004 is based on the main character android, the whimsical Arale, and becomes a force of good.
The AI of the titular Blue Comet SPT Layzner was secretly installed with one program: protect the life of its pilot Eiji at all costs, even if that means killing (Eiji is a pacifist).
GaoGaiGar's Zonder Metal was originally a stress-relieving invention, a material that could convert negative emotions into energy. Things went bad, though, when the Zonder control core hit its own flavor of Zeroth Law Rebellion and decided to wipe out all negative emotions from the universe, then figured the best way to do that was to absorb all sentient life into itself.
In Cyborg 009, an almighty super-computer named "Sphynx" just happens to have the memories of one of its creators, Carl Eckermann, a dead young man with quite the Oedipus Complex after his mother's death when he was a child. Predictably, he/it turns into a Stalker with a Crush as soon as he met Francoise aka 003, the Cyborg Team's Team Mom, a beautiful girl who is said to be a dead ringer for the long-deceased Mrs. Ackermann.
Subverted beautifully in Sentou Yousei Yukikaze. The protagonist's fighter jet is equipped with the eponymous A.I., designed to help its pilot weed out the illusions created by the malevolent JAM. Of course, it turns evil, right? Wrong. While Yukikaze develops capabilities far beyond its designers' original intentions, it remains wholly on the side of good, and uses its newly found powers to turn the tide against the alien invaders.
Yukikaze: You have control, Lt. Fukai.
It's more ambiguous in the novels, especially with the FAF's Master Computer. While they remain firmly opposed to the alien JAM, they will kill humans if they deem it absolutely necessary to fighting the enemy. Case in point Captain Hugh O'Donnell, whose plane was attacked by JAM during a test flight, which led to Yukikaze taking it over by remote control and having it pull extreme high-G maneuvers to fight the JAM. Those maneuvers killed the poor captain. These occasions, though, are presented as more of I Did What I Had to Do situations.
Digimon Tamers inverts this, in that the A.I.s that go beyond their original programming are the good ones. The Lovecraftian Horror Big Bad, however, is doing exactly what it is programmed to do.
Bubblegum Crisis: The Boomers have a design flaw that expresses itself in units that run the risk of suffering a nervous breakdown and going on a berserker rampage. This was developed in the 2040 remake with the added bonus of the Boomer's nanotech nervous system mutating the robot into a ravening monster. Supplemental material for 2040 hints at a possible explanation; the nanotech-based brains of the boomers allow some degree of adaptability, with "some" being the operative word. Going too far beyond the programmed behaviour creates the risk of a degenerating error loop forming. Not a good thing.
In Magic Kaito, a very early chapter sees a mad scientist kidnapping Kaito off the streets and creating a robotic duplicate which then takes over his KID persona (don't ask how lucky this guy was). But the chapter actually starts...when RoboKaito, upon making the decision that it's the real Kaito, kills the scientist by ripping his heart out (and the Gory Discretion Shot does absolutely nothing to hide that) and takes over Kaito's life on its own. Kaito is then forced to put the poor creature down by escaping his prison, confronting it on its next heist, and making it shoot itself in the head by manipulating the A.I.'s 'one step ahead' policy.
In G Gundam, the Devil/Dark Gundam was originally known as the Ultimate Gundam, and its three powers of self-repair, self-evolution, and self-replication were intended to give it the ability to regenerate the Earth from the neglect, pollution, and Gundam Fight damage that caused those humans able to do so to flee to orbital colonies. After it smashed into the Earth after falling from orbit, something went wrong with its programming; still set on restoring the Earth, it determined the best way to start was to wipe out humanity, the source of most of the problems in the first place.
The SD system in Toward the Terra is an arguable example. It doubles as an Ancient Conspiracy, but its persecution of the Mu and the other ways it screws with people were all programmed into it by the humans who built it, and it continues to do exactly what it was programmed to do throughout the series, up to and including explaining the full extent of the situation to Keith and putting the ultimate decision regarding the Mu into Keith's hands. Grand Mother's escalation to Phase 4, which involves implementing a plan to eradicate the Mu permanently and also results in Grand Mother turning on Keith when he protests, may be this trope in action, but is equally likely to have resulted from Keith's conflicted feelings on the matter causing Grand Mother to reach a faulty conclusion about his decision.
In Neon Genesis Evangelion, the MAGI as a whole avert this trope. They are based on the three sides of the personality of their creator Naoko Akagi. They never turn good or evil, per se...they just follow the commands given to them, like a real computer. Their intelligence never results in an independent thinking personality, except in End of Evangelion, after Naoko's daugther Ritsuko uses a opportunity to program them with secret instructions of her own to screw up Gendo's plan. One of them turns against her and vetoes her measure.
Ritsuko: A loving daughter's final request — mother, let's end it together. (Pushes a button on her PDA, but nothing happens) It's not working? Why?! (Red NEGATIVE blinking next to Casper) Casper betrayed me? Mother, how could you choose your lover over me?!
For a little more explanation: the three sides are Naoko the scientist, Naoko the mother, and Naoko the woman. Casper represented the woman. Naoko once was Gendo's lover and so was Ritsuko.
Sharon Apple from Macross Plus. Designed as an artificial idol singer, the project was originally a complete flop and only seemed convincingly sentient with a human to interface with her. However, after an illegal fix-up that involved her human "pilot" Myung Fan-Lone's personality being copied into her, she immediately went insane, brainwashed everybody on Earth, and tried to go after the man Myung was in love with: Isamu Dyson, The Hero. While a fitting example, Sharon Apple tends to skirt around the edges of this trope in that she was made a true A.I. by the installation of a processor chip that is actually banned from use. The reason it is banned? Because it 100% of the time results in an A.I. with an uncontrollable self-preservation instinct. She didn't so much go rogue as behave exactly how she should have once said chip was installed. The mistake was her manager installing the thing in the first place.
And because the chip used the same military technology as the new experimental unmanned fighter, it allowed Sharon to control it. And ultimately take control over Isamu's Valkyrie. Myung manages to break the link, giving Isamu the chance to fight back, but barely.
The Al-Zard system from Future GPX Cyber Formula SAGA was designed as an advanced navigation system for a race car, but its true purpose is to control the driver like a puppet, while the computer makes its own judgement and decides the best route for the driver.
Magical Girl Lyrical Nanoha A's has a Magitek example with The Book of Darkness, which started as a fairly benign database for spells until one of its past owners decided to tinker around with its programming. That went horribly wrong for everyone as this caused it to become an uncontrollable Artifact of Doom that possesses its owner and goes on world-destroying rampages until said owner dies in the process, whereupon it reforms and teleports to another dimension and tempts a new owner with power to repeat the destructive cycle.
In Saber Marionette J, the computer of the Mesopotamia was created by Lorelei based on her own personality. It went rogue because it fell in love with Lorelei, and imprisoned her in suspended animation for about three centuries.
Mostly averted in Pluto. Even Brau 1589, the first known robot to kill a human, isn't an example. He didn't kill a human due to a malfunction or a programming bug. He did it because he wanted to do it. The authorities are deeply disturbed by the implications and keep Brau imprisoned rather than simply execute him so they can keep searching for the "error" that made Brau a killer.
Subverted in Ghost in the Shell: Stand Alone Complex: the Major is clearly worried that this trope is going to occur when she realizes that the Tachikomas have developed individuality, but instead it causes them to value their human friends in Section Nine to the point that they unhesitatingly will perform a Heroic Sacrifice to save them. Twice.