That's overly idealized and wrong view. Meditation together with mental treatment often works really well but they are not direct substitutes. There are meditation therapies that mix the two.
What meditation does to the mind is not completely separated from the mental health, but it's not on the same line either. Understanding the nature of your mind heals only minor neuroses, and sometimes with depression.
You can be mentally ill and still have "prajna wisdom" or being "realized" in a very fundamental way. "Prajna wisdom" does not translate directly into normal wisdom or mental health (can help in some cases). The history is full of mentally ill meditation masters, "funny monks" and "crazy wisdom" that is crazy in real way and just not metaphor.
In religious settings people have tendency to attach attach every good thing to meditation in linear way. Morality, mental and physical health, everything. In reality you get "something completely different" (in the Monty Python way). It can help you in other things but it never solves other problems in your life.
In the case of Hakuin he said himself he was very ill.
In many other cases the description of "demons" and other things match what is now called psychotic episodes. There is difference with struggling with practice and being unwell.
The root teacher of Jamgon Kongtrul The Great was a man called Patrul. Patrul was a notorious drunk, and was known to beat up his students. He was still a kind man, and a legendary teacher.
Having psychological flaws doesn't disqualify you from being a realised master and a great teacher.
What meditation does to the mind is not completely separated from the mental health, but it's not on the same line either. Understanding the nature of your mind heals only minor neuroses, and sometimes with depression.
You can be mentally ill and still have "prajna wisdom" or being "realized" in a very fundamental way. "Prajna wisdom" does not translate directly into normal wisdom or mental health (can help in some cases). The history is full of mentally ill meditation masters, "funny monks" and "crazy wisdom" that is crazy in real way and just not metaphor.
In religious settings people have tendency to attach attach every good thing to meditation in linear way. Morality, mental and physical health, everything. In reality you get "something completely different" (in the Monty Python way). It can help you in other things but it never solves other problems in your life.