From the AD&D DMG, pg 28:
"Sooner or later a player character will change alignment. A character might change alignment for many reasons, most of them having nothing to do with the player 'failing' to play his character's role or the dm 'failing' to create the right environment. Player characters are imaginary people, but like real people they grow and change as their personalities develop...These are natural changes. There might be more cause for concern if no player character ever changes alignment in a campaign."
"There is no rule or yardstick to determine when a character changes alignment. Alignment can change deliberately, unconsciously, or involuntarily. This is one of those things that makes the game fun-players are free to act, and the DM decides if (and when) a change goes into effect. This calls for some real adjudication."
It goes on to talk about unconscious change. "Unconscious change happens when the character's actions are suited to a different alignment without the player realizing it...If the DM suspects that the player is not acting within his alignment, the DM should warn the player that his character's alignment is coming into question. An unconscious alignment change should not surprise the player, not completely anyway."
So a CG dwarf could absolutely kill a good necromancer. According to the 2e DMG the DM might advise the player that this is not a good act and his character's alignment might change. The PLAYER would then know. The CHARACTER would not know. The PLAYER would then decide if he wanted to perform the action anyway, and explore how he was now neutral or evil, and the CHARACTER would go on acting much the same as before (though would now be vulnerable if a cleric cast holy word).
From the 3.5 DMG, page 134:
"A character can have a change of heart that leads to the adoption of a different alignment. Alignments aren’t commitments, except in specific cases (such as for paladins and clerics). Player characters have free will, and their actions often dictate a change of alignment."
"You’re [i.e. the DM] in Control: You control alignment changes, not the players. If a player says, 'My neutral good character becomes chaotic good,' the appropriate response from you is 'Prove it.' Actions dictate alignment, not statements of intent by players."
And finally, from the 3.5 PHB, page 103-104:
"[Alignment] is not a straitjacket for restricting your character. Each alignment represents a broad range of personality types or personal philosophies, so two lawful good characters can still be quite different from each other. In addition, few people are completely consistent."
"Choosing an alignment for your character means stating your intent to play that character a certain way. If your character acts in a way more appropriate to another alignment, the DM may decide that your character's alignment has changed to match her actions."
Also from the 3.5 PHB, page 103:
"Good and evil are not philosophical concepts in the D&D game. They are the forces that define the cosmos."