Sometimes they do and sometimes they don't. I had a seizure because of medication I was put on for a mental illness I didn't believe I had. I wasn't 18 and my parents essentially forced me to take them. The pills didn't do anything for me besides give me a seizure that easily could've killed me (I was hospitalized).
There's also actual research suggesting these pills can increase suicide attempts.
https://www.ncbi.nlm.nih.gov/pmc/articles/PMC3353604/
There is enormous money to be made suggesting these pills are useful, so I don't just assume it to be true. I also know many other people who feel anti-depressants ruined their lives. I also know many people who feel anti-depressants saved their lives.
It's not black and white. Personally, I feel the efficacy of pills for mental health are greatly exaggerated - but it's easy to see why I might be biased.