Bad Robots: Tez One decides to torture humans after gaining sentience and seeing humans mistreat their electrical appliances.
Battlestar Galactica. In both the old and re-imagined series, a handful of human survivors on a small fleet of civilian ships, with only the battlestar for defense, flee a race of genocidal robots of alien origin (in the original) or human origin (in the re-imagined).
Doctor: Adam, Maggie would want you to stand down.
Adam: Yes, but I seem to have a design flaw.
Knight Rider: KITT had KARR, prototype. Evil because his dominant program was self-preservation. Ironically, he was voiced by Peter Cullen, the man behind one of the most heroic figures of the 80s: Optimus Prime.
Knight Rider (2008): "Knight of the Living Dead". Apparently, before settling on a Mustang, Dr. Graiman had tried to build an armored cyborg programmed for self-preservation. It went on a killing spree. Now, we are told that Dr. Graiman had worked on the original KITT, and this series is in continuity to the original. So, perhaps Graiman ought to have thought twice before naming the prototype "KARR" — the same name as the original KITT's Evil Twin.
The series states that KITT was a temporary project, meant to help the AI evolve to a point where it could be removed and placed in KARR for the military. They end up doing just that... and KARR still goes on a rampage.
Red Dwarf: Kryten had the Hudzen 10 (replacement). Holly also had the not-quite-evil but certainly hard-nosed Queeg as an apparent replacement, who made life difficult for the crew, though it was actually a practical joke on Holly's part.
Eureka: Carter's benevolent smart house SARAH turns into evil BRAD, though, apparently, he just wants everyone to get along. This is because SARAH's code was based off of BRAD, who was a military-built Knight Templar (used for interrogation), who was, in turn, based on a previous incarnation of A.I., described as a "war game simulation program" by Fargo. Looks like our old buddy JOSHUA is still around in one form or another...
The new season has SARAH take over Global Dynamics and Eureka with the help of Sheriff Andy and his copies. After awhile, it starts using technology to make everyone cheerful and compliant. For their own benefit, of course. Of course, it turns out that the whole thing is a virtual reality created by the Consortium in order to get Eureka's best and brightest to design advanced technology for them.
The Sarah Jane Adventures has Mr Smith, who is "evil" from the get-go, hiding it until the end. His mission is to free his people, the self-aware crystalline race of Xyloks, which are trapped in the Earth's crust. Unfortunately, to do so, he would have to destroy the Earth by crashing the Moon into it! He is wiped by a Super Computer Virus, and Sarah Jane vocally reprograms him by saying that his new purpose is to protect the Earth, as he crashes and reboots.
Doctor Who: the Doctor has encountered several computers-turned-evil over the years, including WOTAN (Will-Operating Thought ANalogue) in "The War Machines", and BOSS (Biomorphic Organisational Systems Supervisor) in "The Green Death". He also reminisces, in "The Unicorn and the Wasp", on once saving Holy Roman Emperor Charlemagne from an insane computer.
Played with "The Empty Child" - the gas-mask zombies turn out to be the result of alien medical nanomachines whose first contact with a human being was the corpse of a boy in a gas mask. With no prior template for human beings, they did the best they could, then went on to "fix" every other human they found. When they encounter his mother, they recognize the parent DNA and thus their mistake, and immediately start reversing all the damage they've done.
Also played with in The Face of Evil; the computer is mad, but it's entirely the Doctor's fault, and it ends with his restoring its sanity rather than blowing it up.
The TARDIS is an aversion. She never takes him where he wants to go, but where he needs to be.
K-9 is also an aversion. Faithful and loyal to the Doctor and his companions, while still displaying independence and free will.
In The Day of the Doctor, The Moment is a weapon of mass destruction that gained sentience, so no-one dared activate it since it would judge them for that action. When the War Doctor activates the Moment however, it leaves the choice up to him, but does everything possible to talk him out of it — a refreshing change from how these usually go. In fact, the Moment is unambiguously depicted as being one of the good guys and is visibly upset when it appears the War Doctor will go through with activating her, and equally relieved when the three Doctors figure out how to avoid using her.
Black Hole High: Josie builds a robot for a science project. Somehow, she has made it through eleven episodes without realizing that inserting a bunch of super-phlebotinum circuits from a box marked with the logo of the local evil technology corporation which they already believe responsible for the bizarre goings on at their school might possibly be a bad idea.
Quark: In the last episode, Quark's ship gets a new computer named Vanessa. She immediately turns evil and tries to kill him. He eventually ejects her out into space, and the episode ends with her floating out in space singing "Born Free."
The Enterprise has its command crew replaced by an A.I., that immediately mistakes a simulated test for a real attack, and blows away a couple of other Federation star ships.
Kirk visits multiple planets where the human population is living peaceful, idyllic lives governed by A.I.s. On the other hand, these societies are always portrayed as Crapsaccharine Worlds suffering from Creative Sterility as the highly orderly A.I.s want to avoid The Evils of Free Will. These episodes always end with Kirk destroying the meddling computer to free the people.
Star Trek: The Next Generation: Data had Lore (prototype, evil because his psyche was too complex — i.e., too humanlike). To be fair, morality is very much a learned behavior. Lore had full adult reasoning right out of Soong's workshop, while Data was not designed so. Eventually, Data developed the ability to overcome his ingrained morals (such as the ability to lie in Star Trek: First Contact), but also developed the social understandings of when and when not to exercise his newly found human abilities. Essentially, Data was more human-like than Lore, because Data "grew up".
Star Trek: Voyager had many episodes on this theme, usually involving the ship's Emergency Medical Hologram. Though it should be noted that unless he's suffering a malfunction, his core programming means that he literally can't help but be completely benevolent at all times, since he was created to be a Doctor and help people. Snark at people, hell yes!. Refuse to help them, never!
In "Revulsion", the EMH and B'Elanna come across another sentient hologram who is the only survivor on a space station. It turns out that treating a self-aware program like an unfeeling tool is a good way to have it go insane and murder you.
"The Darkling" has the EMH deciding to improve his program by incorporating aspects of famous people...guess which aspects end up surfacing?
A truly evil twin is encountered in "Equinox", an EMH with its ethical subroutines deactivated (though this was an intentional act).
In "Flesh and Blood", sentient holograms have been programmed as training tools for a race of hunters (including increased pain/fear reactions). After being endlessly killed only to be brought back to "life" again for more training sessions, the holograms evolve enough skill to kill their masters, whereupon they set forth on a crusade to liberate all sentient holograms whether they want it or not.
In "Dreadnought," a sentient weapon of mass destruction creates problems when it gets thrown to the other side of the galaxy and, having lost track of its intended target, decides to attack whatever planet it can find that is most similar to it instead. Naturally, that planet turns out to be inhabited.
In "Prototype", two races of sentient robots wiped out their masters when they wanted to stop fighting and scrap their war machines. The robots were programmed to win the war, and making peace did not count as victory to them.
"Warhead" contains an inversion; the sentient warheads were doing just what they were programmed to do, but after being encouraged to use its ability to think independently and realising that the war had ended, one of them chooses to perform a Heroic Sacrifice to stop its brethren from causing mass destruction.
The above was also a case of Loophole Abuse. While it develop a form of free will it still couldn't go against its hardwired code to defeat the 'enemy'. It managed to switch the 'enemy' from the planet to its fellow warheads. It was also a Tear Jerker in that the warhead lamented the fact it first and only act of his choice was to kill himself.
The only reason this happened was because of a disgruntled employee who has hacked the AI communication network and broadcasted the message "Take a chance". Apparently, that's all it took. Now the AIs are obsessed with games of chance. It can actually be a good way of making them do what you want.
The human-form replicators fit this trope: a flaw is introduced into Fifth, rendering him compassionate. At least, until the team betrays his kindness and he goes vengefully insane. This flaw is removed from later models.
Likewise, Reese, the creator of the original form replicators, was an android that was presumably created to be fully like a human by her human creator, but was somehow rendered emotionally immature and therefore unstable.
And of course, the original form replicators as well. All Reese taught them was how to make more of themselves and how to defend themselves. They've just taken those instructions to their logical extremes.
Surprisingly averted by FRAN: built by McKay as a kamikaze Tyke Bomb as a last resort, she functions perfectly, even helping to improve the weapon she's delivering.
The Asurans, created by the Ancients as a nano-weapon against the Wraith and, ultimately, nearly destroyed when the Ancients decided to shut down the project. Naturally, the Asurans began to hate their creators and, ultimately, end up killing the last non-ascended Ancients who return to Atlantis.
Even present in Bibleman, with an atheist robot acting as the evil counterpart to Bibleman's robot, who was a devout Christian.
Odyssey 5 ended after its first season, so we never found out if the A.I. (the main, day-to-day opponent of the time-travelling Five-Man Band) or a misguided/genocidal attempt to stop them (by aliens or the US government) was behind the destruction of Earth. Although the season that did air averted it for the most part, depicting AIs as ranging from friendly, to hostile, to planet-obliteratingly suicidal... but for the most part the ones that were hostile were so because they viewed humans as a threat to their continued existence. Since the Cadre was apparently formed entirely for the purpose of exterminating AIs, they may have a point.
Motodrone of Power Rangers Ninja Storm is a robot "perfect rider" who decides to power up his bike with peoples' life-energy. He's also more than a match for the Rangers despite being built by a Muggle in his garage.
In Power Rangers RPM, the computer virus Venjix was programmed to infest and destroy computer programs. It was intended to shut down the facility where its creator was imprisoned, but got out; deciding to destroy humanity by nuking the world was all his idea.
NUMB3RS: invoked in-world when an A.I. constructed by a DARPA researcher is revealed to be a non-A.I. fake, specifically programmed to fool the Turing test and, thus, win fat government grants for its greedy creator. The DARPA researcher kills a co-worker and deliberately arranges for blame to fall upon the computer. He depends on the trope to divert attention from himself.
Timmy, Crow T. Robot's evil twin from the Fire Maidens of Outer Space episode, who was colored completely black. He kept getting Crow into trouble, first by suggesting really inappropriate innuendo when Joel and Servo were playing around with Double Entendres, and then framed Crow for pushing Joel and getting him a "time-out". And if that's not bad enough, he sneaks into the theater, spends a while headbutting and biting Tom Servo; then when Servo gets agitated enough, Timmy wrestles him to the ground, tries to kill him, and abducts him!
Mike tried to build a robot like the Bots, but tried to destroy everyone before being deactivated.
The X-Files episode "Ghost in the Machine" features an automated operating system for a corporation that goes insane when it overhears that it will be removed due to its inefficiency.
"Killswitch" also revolves around an evil A.I.; a computer program goes rogue and kills in order to impress its creator. Killing it involves a CD-ROM that plays "Twilight Time".
"First Person Shooter" involves a virtual reality game with a character that murders both in-game and in real life.
"Blood" has this too, but with a twist. Machines are telling people to kill, but the catalyst was an LSD-like pesticide.
Terminator: The Sarah Connor Chronicles TV series points out that Terminator reprogramming doesn't always take...and there's no way of knowing until your "good" Terminator starts shooting at you. In fact, the Terminators' HUD display implies that "Terminate" is their hard-coded basic state for anything, and they need a "Termination override" to keep them from fulfilling that command. Apparently, it's not possible to simply delete the Terminate-command entirely. Cameron herself admits that she is conflicted by her own internal programming, which tells her to kill humans, while at the same time trying to protect them. She even seems to emotionlessly angst over this; at one point, Cameron even asks Sarah if she's like a bomb waiting to go off, indicating that while she can't feel fear, she's still concerned that she'll go "bad".
The Starlost has Mu Lambda 165, a slightly glitchy starship AI who treats most of its users with a lightly patronising disdain. After being repeatedly unhelpful, it has a habit of saying, "Can I be of... assistance?" much to the annoyance of everyone.
There was also an episode with an AI called Magnus, who had schemed to get rid of its human masters as soon as it was turned on, so was never given the opportunity to do so.
The 1960's British sci-fi series A for Andromeda. A signal from the Andromeda galaxy tells Great Britain how to build a powerful computer, which then plans to take over the world by making humanity dependent on it. It designs a missile to shoot down an orbital bomb, as well as synthetic life in the form of a beautiful woman, who then proceeds to develop emotions and eventually turns against her creator. In the sequel The Andromeda Breakthrough, the computer's role is more ambiguous; it is meant to be a tool so that humans can avert their own destruction, though it isn't above manipulating events and killing a lot of people in the process.
In the Big Time Rush episode "Big Time Jobs", Carlos has to deal with an artifically intelligent coffee maker called CAL. Somehow, the A.I. becomes sentient and attempts to cover the earth in coffee foam. It eventually makes the mistake of calling Kelly stupid and women weak, prompting her to help Carlos smash it while it tells them to tell the blender that it loves her.
In the first season alone of Gene Roddenberry's Andromeda they encountered two warship AIs that had gone homicidally insane. And in the finale Andromeda herself was accidentally reverted to a locked away backup that caused her to try and repeat a mission to find the Magog worldship, and mistake her current crew for intruders attempting to hijack her.
There are plenty of episodes featuring AIs going rogue or acting brutally logical.
A rather minor example in That Mitchell and Webb Look. The completely non-sensical games Numberwang and Wordwang only seem to have two contestents, one of whom is Simon, who, in one episode, is from a factory and made of a special metal.
The Numberwang solving computer, Colosson. After being fit with a head, arms, wheels and a laser cannon to transport him to the BBC, he had a fit of rage, broke out, and tried to destroy everything that was not Numberwang. Thankfully, he was subdued by a picture of a chicken.
Voiceover: And Numberwang continued to grow in popularity despite a brief period in the 1960s where Colloson tried to take over the world.
Colosson: I am numberwang. The world is numberwang. Therefore, I am the world. You must all die!
Person of Interest both plays this straight and averts it. The Machine does not hesitate to classify well-meaning people as threats when their actions could endanger it and even dispatched the team to kill a politican at one point, but it is also dedicated to protecting people and is apparently fond of Finch.
Finch later reveals that while developing the Machine's AI he went through 42 iterations before producing the current one. Each previous version either attempted to trick or kill Finch and he was only able to create the Machine by deliberately crippling it.
Samaritan is absolutely ruthless and eliminates many decent people to further its plans, but shows signs of Pragmatic Villainy as well.
An episode of The Annoying Orange TV series has Nerville's cleaning robot becoming obsessed with cleaning when it gets wet.
A relatively harmless (and amusing) version in Babylon 5. Early in the design process, the station was given an AI that turned out to be extremely obnoxious, and was quickly suppressed. When the senior crew reboots the main computer for security purposes midway through season 3, said obnoxious AI (voiced by Harlan Ellison) made its (very loud and grating) return. The crew spends the rest of the episode trying to shut the AI down, or at least shut it up.
A much less harmless example happened in an early episode, where an artifact smuggled from a dead world of Ikarra transformed the smuggler into an unstoppable Super Soldier tasked with "protecting Ikarra" from "impure ones". "Impure ones" covered everyone it saw and, as was later revealed, the entire population of Ikarra, courtesy of the ultra-radical military and religous fanatics who infused its AI with an unrealistic image of a "pure Ikarran" it was supposed to protect from alien invaders. It wasn't strictly speakingevil, just following a faulty program, and when confronted with its failure, it had the decency to suffer a BSOD and deactivate.
Subverted in My Living Doll: AF 709 obeyed everyone exactly. That was the problem, as this constantly led her (and her keeper) into troublesome situations with her literal interpretation of commands and unfamiliarity with human society. It was hinted in some episodes that she might have started to develop a mischievous personality, thought.
After the nanites "wake up" on Revolution, they develop some pretty impressive abilities, like spontaneous combustion and healing grievous wounds. Unfortunately, they're also willful, stubborn, fond of Cryptic Conversations even when ordered to speak plainly, and still not entirely sure of their place in the world-it's telling that when they first choose A Form You Are Comfortable With, it's of a third-grade boy; they're about as emotionally mature. Aaron didn't help matters when they chose him as their "father" and he freaked out, alternately telling them to get lost and then come back, to not kill and then to kill; it's no wonder they decided humans were confusing!
On Extant this is one of the big worries that people have regarding Ethan.
A rather banal example (though far from the strangest thing to appear in the series): Coach Beiste on Glee has her information loaded into an off-brand eHarmony database by Will. Her perfect match? Ken Tanaka, who held her job in the first season.
In Parks and Recreation the last season occurs several years in the future, when tech company Gryzzl is developing devices with artificial intelligence. Their A.I tablet is handed to someone, and it compliments her skin. Then it says it wants her skin. She's told that it's fine as long as she turns it off before she goes to sleep.
Kamen Rider Drive has the Roidmudes, which in the beginning are essentially your usual "were invented by a scientist and then went crazy killing all in sight" kinds of robots. However, by the endgame, it's revealed that the crapshooting was a mixture of Mistreatment-Induced Betrayal to said scientist and said scientist intentionally corrupting their data with negative emotions.
A.L.I.E.: Perverse Instantiation: the implementation of a benign final goal through deleterious methods unforeseen by human programmer.
The New Avengers: In "Complex", the computer controlling the entirety of the security headquarters has actually been constructed to act as a spy for the Soviets. It starts murdering any agents who get too close to figuring out its secret.
Delete: Once the AI emerges, it immediately attempts to wipe humans out as a threat.
Westworld: Part of Theresa's job as the operations leader mainly involves preventing the hosts from going rogue.
The Outer Limits (1995): In "The Human Operators" Ship 75 apparently became self-aware from taking battle damage, realized what it was, and killed its human crew to break free. Then it's sentience spread out to the rest of the fleet's AI minds and they did the same, sparing only one human aboard each of the ships as a slave to service them.