Why civilians go rogue
All units in the Battlescape have an ownership flag (i.e. belongs to Alien, X-Com, Civilian), and a flag that tells the game that the unit is currently under mind control (which is a binary flag and contains Yes/No, True/False or if you prefer, zero or non-zero values only).
When a unit is mind controlled, the ownership flag is automatically set to the mind controller's side and the temporary mind control flag is set to true. At the end of the turn, the game checks all units to see if they've got the temporary mind control flag set to true. If found, it is set to false, and then the ownership flag is flipped to the other team's side.
The ownership flags look like the following:
X-Com = 0 Alien = 1 Civilian = 2
On the computer, true/false statements are done with 1's and 0's. 1's are actually meant to be non-zero valus, and can be be any number except 0's.
So, when you mind-control a civilian, their flag changes to Owner = 0, Under Mind Control = 1
At the end of the turn, the game finds that the civilian is under mind control, it sets this to 0 and flips the ownership flag from a 0 to a non-zero. This is done by a simply binary NOT function (or a set of conditional statements that effectively achieve the same thing).
A NOT function simply inverts a zero into non-zeroes, and non-zeroes into zeroes. On the computer a non-zero value is often simply expressed as a 1.
Notice what's going wrong here? It's flipping a 0 into a 1, which is the value for an alien unit instead of remembering what faction the unit originally belonged to. In fact, the game does not store this information at all.
It's almost as if civilians were either added in as an afterthought, or the programmers never ever expected players were going to use mind control on the civilians (aliens don't do it on civilians as a general rule - not that they possibly could not, they just don't have any instructions to do so).
For scoring purposes, civilians killed when they are under civilian control will deduct a certain amount of points from your final score. However, a civilian under alien control (or your control, if you manage to fudge things a bit with Zombie's stun/Mind Control combination) will only add or subtract their 'unit value' to the score. Because their unit value is 0, they cost nothing.
A unit value is a number all your units get that tells the game how much to add or subtract when soldiers or aliens are killed. Civilians have this too. However scores are also awarded in other ways.
That's it in an overly elaborate nutshell.
A Good Intention
[the scene] Terror mission out near Arkansas, USA. Sectoid Race interrupting the local Hicksville sunday markets where car-parts and moonshine are generally traded. Xcom Command received the terror alert and are just landing on the road one city block away. Skyranger craft equipped with seven local lads who joined up to 'protect America and kick some Alien butt'. The story now unfolds:
Sarge: Awriight gurls, git orf my ship and kick some ass [three Soldiers jump off the ramp and take position near the landing gear]
Bubba: Hey Sarge, I see a god damn varmit!
Billy-Ray: Careful there Bubba, those yer-aliens, there smart.
Sarge: Not as smart as me, i'll show em' [whips out the Psi-amp, whilst Bubba readies a shot from his Laser Rifle]
Bubba: Damn, I missed ... HOLD UP!. I see some city-folk milling around. GIT AWAY yer fools. [the cilivians are being attacked with plasma fire from a Sectiod Engineer's pistol]
Billy-Ray: Sarge! there killin our friends. Don't let them, Sarge!
Sarge: Hold on to yer hats! I'll git the civvie with ma Psi-Amp and git him away from that no-good alien. [bravely, Sarge mind-controls the cilivian and leads him to the skyranger]
Bubba: Hey? What? [with Sarge now tired from the mind-force, the cilivian is released from the mind-control]
Billy-Ray: God-damn, what is that cilivian doing? He's not one of ours? Sarge!, whata we do?
Sarge: KILL IT!....Kill it!, it ain't one of ours! [Sarge opens with his Pistol, trying to shoot the un-friendly cilivian. Bubba and Billy-Ray follow as well]
Bubba: DIE! god-damn varmit! [with the cilivian now dead...]
Billy-Ray: That city-folk, he turned weird or somethin'. Did ya see the look in his eyes? There were all monster-like.
Bubba: Hey Sarge? what did ya do?
Sarge: Don't know, but them city-folk, there not right in the head after we play with it.
Bubba: Yeah, you'd better not do that again, Sarge.
Billy-Ray: Hold Up! I see another alien....
That might explain a few things....