You're not doing anything wrong. Speaking from experience, sometimes there isn't anything you can do. Emotions and psychology are immensely complicated. There's a reason that, despite these things having been a field of study for about a century, we still are pretty clueless as to how it all works. Everyone is unique, and what helps one person feel better won't always help someone else feel better. Sometimes, someone just needs someone to talk to and provide some friendly support, and that's it. But for some people, all the support and acts of kindness in the world won't budge their emotions.
The best people to trust with helping with those kinds of issues are professional psychologists who understand all the invisible components at play and can put together a more holistic understanding of people's problems. The trouble is that being able to go to therapy, finding a therapist that's good for you, and being able to attend sessions for weeks and months isn't always easy. Because those resources are unfortunately not always accessible or a good fit for you, and it takes time to build a relationship and understanding between the therapist and patient and be able to unpack the issues in an accurate way.
So the best thing you can do, depending on whether this person is online or someone close to you, is to help them find a therapist, clinic, or some other resource that they can go to and that can help them with their issues. You're doing your best, but you're not a trained psychologist who can diagnose and attack the problems that go on in the mind. Sometimes, the best way to help is to simply direct people to a place that can provide better help. Beyond that, all you can do is pray.
This is, of course, speaking rather generally, so if I'm off the mark and not being helpful, feel free to disregard.