An affirmative defense is a defense plead, before trial, in a civil proceeding. The phrase is not usually used in the context of a criminal trial.
So, what we are talking about, at least your first inquiry, is a run-of-the-mill defense. A defense to a crime is not plead, it's presented by way of evidence (circumstantial and/or direct) when the government has rested (and survived a motion to strike their evidence for failure to prove, as a matter of law, their prima facia case- each element of the offense). The defendant's burden is not "absolute" nor is is beyond a reasonable doubt. The defendant merely has to create enough reasonable doubt as to guilt and/or that the action was justified in light of the defense. The classic example is self defense in an assault and battery case. A defendant is allowed to use such force necessary to repel an aggressor's attack. If, in the course of that "repel", he batters the aggressor, his crime is justified under self defense.
Insanity is a whole other story. Insanity defenses, like an affirmative defense, must be raised prior to trial (number of days depends on the state) and, rather than a defense justifying behavior, it is an "excuse" as to the criminal conduct. The "plea-before-trial" requirement is there traditionally so that the court and/or the government can have their own experts examine the defendant to see if he really was legally insane at the time of the offense (unlike incompetent to stand trial- different standard). The insanity test (majority rule) is called the McNaughten test and basically boils down to whether or not the defendant truly appreciated the criminality of his conduct at the time of the offense. There is also the "irresistible impulse" test and other variations depending on your state.
Generally, you may claim other defenses along with insanity, however, as a practical matter, it's hard given the amount of detail that goes into a pych examination.
Two years ago I plead a defendant to second degree murder for shooting his roommate in the head point blank and emptying the remaining five rounds in his back. My client was schitzophrenic and, according to my experty, legally insane at the time of the act. The commonwealth's attorney had two experts (slightly more persuasive than my own) who said differently. In the end, we agreed to 2nd degree with a cap and I was able to put on my evidence as to insanity at the sentencing hearing in mitigation. So, even if you plead guilty, you sometimes can still put on defense evidence.