Yeah, the Federation is so enlightened that they have penal colonies. Not just penal colonies on an island or something, but on a whole planet. Yep, they have prison planets.
With crazy insane doctors who love experimenting on prisoners.
It's never explained in this episode why Dr Adams went nuts and started zapping people. Nobody even asked the question. I suppose it was par for the course for a Federation prison colony planet.
Transcript
1
Captain's log, Stardate 2715.1. Exchanging cargo with Tantalus V penal colony.
Radio voice: We're beaming up a human-sized box without checking what's in it.
Berkeley: Roger. I'll leave it unattended while I check penal colony security procedures.
2
Caption: Inevitably, the inevitable happens... {man climbs out of box on the transporter platform}
3
McCoy: Penal colonies are barbaric!
Kirk: No, they're very humane.
Uhura: Captain, Tantalus says one of their convicts, sorry, "inmates" has escaped.
4
Caption: They catch him.
Van Gelder: I'm Simon Van Gelder, director of Tantalus. Dr Adams erased my mind!
Spock: Records confirm his identity, Captain.
5
Kirk: Dr Adams, what's going on?
Dr Adams: {over radio} I can explain. Beam down yourself, Captain, with no security team.
Kirk: Well that doesn't sound suspicious. Okay.
6
Caption: On Tantalus V:
Kirk: Are you erasing inmates' memories?
Dr Adams: Don't be ridiculous! Oh, this my assistant. She's a former inmate. Her name is Lethe.
Caption: {arrow pointing to Dr Noel} Psychiatrist Kirk seduced at Christmas party. Her name? Dr Helen Noël.
7
Dr Adams: This is our neural neutraliser. Unfortunately Van Gelder used it on himself.
Kirk: Does it erase memories?
Dr Adams: Don't be silly! Does it, Lethe?
Lethe: I don't remember.
8
Kirk: Let's see if this... thingy erases memories. Use it on me.
Dr Noel: I... just did, Captain.
Kirk: Well that's not very conclusive.
Dr Noel: Four times.
Kirk: Try it again.
9
Kirk: Crawl through this duct and turn off the force field so Spock and McCoy can beam down. Know anything about hyperpower circuits?
Dr Noel: No.
Kirk: Touch the wrong wire and you're dead. Off you go.
10
Dr Adams: Now, now, Captain. Let's just erase your mind.
Kirk: Wait... So now it does erase memories?
11
Caption: Power off! Kirk punches Adams! Leaves him under beam! Power on!
12
McCoy: He's dead, Jim. His mind completely erased.
Spock: So, why did Adams start attacking people?
Kirk: You know, I don't remember.