On Earth, mental health services are a recent development; they hardly existed before two hundred years ago. Before that, people were often thought to be touched by the devil, possessed, or some other nonsense. Many were either killed or confined, whether in more official places like an asylum or in the basement of a village resident assigned to care for these prisoners, who might be shackled day and night. Sometimes sane people were dealt with this way when they went against powerful people or social movements, calling for change.
We can do the same in a fantasy setting or inject our modern compassion and understanding into the world. In SF, it’s reasonable that advances in health care parallel those in other areas of technology, but it’s not a rule. We’ve all seen seemingly dystopian SF where ships, space stations, and characters are all filthy and lawlessness seems to predominate; both physical and mental health needs may suffer, too, as the latter can almost be considered a luxury. The case can be made that the development of machinery helps provide for basics like food and shelter more easily and that “free time” is subsequently available for professions like psychology, but when people are struggling to get food, no one wants to spend time helping a disturbed person.
One reason all of this impacts characters is that people hear psychological terms, should they exist, and use them just as we do. But that depends on information flow. It’s better in SF, in theory, than in fantasy, as is education. Even a dystopian society where that education system has disintegrated might still be aware of the terms, if they entered common usage before the collapse. Do we want our characters using such terms? They’re optional. The term “ego” hadn’t been invented in medieval times, but people were aware of it, anyway, using other words like pride.