For example John Wayne Gacy underwent psychiatric evaluation and "Two doctors concluded he had an antisocial personality disorder (the clinical term for sociopathy and/or psychopathy), was unlikely to benefit from treatment, and that his behavior pattern was likely to bring him into repeated conflict with society. The doctors concluded Gacy was mentally competent to stand trial[0]."
After that he was granted parole and released from prison and in the following years he murdered more than 30 young boys. So yea, the system failed us all. Although it is hard to evaluate and predict who will turn out to be maniac killer out of thousands and thousands of psychiatric cases health system deals with.
[0] https://en.wikipedia.org/wiki/John_Wayne_Gacy#:~:text=Two%20...