There is a weak and poorly funded mental health system in the States. People with good support systems and good health insurance cannot get proper care. If one is not affluent and/or cooperative care is dismal. When institutional programs for the mentally ill were closed the idea was to transition to community based care. This transition was never seriously funded, funding has been cut, any community care that worked withered and died. Community care can be as basic as having someone to remind and/or encourage people to obtain and take their meds. Chicago closed half of its public mental health clinics in 2012. Early in my career one of my duties was transporting mentally ill people to hospitals or state mental health facilities. I had many regular customers. Several times I took the same individual for care twice in one shift. The mentally ill were "freed" from institutional settings and they were abandoned. There is no way for the mental health system to aid in prevention of attacks.

As for lone or pairs of shooters there is nothing that can prevent them from acting if they keep quiet about their plan. Anders Breivik wrote about this in his manifesto.