A criminal defendant that is presently incapable of understanding his former actions or the intent behind those actions will likely be found incompetent to stand trial
A defendant who cannot appreciate or understand the criminal charges being brought against them and is found to be unable to assist in their defense may be judged incompetent to stand trial.
A court cannot try someone who is mentally incompetent. Similarly, it is believed that one who is deemed mentally incompetent is also likely incapable of forming the requisite criminal intent necessary to be convicted of a crime.
The defendant is not let free but rather is institutionalized until such time that competency returns.