Some people talk about it as a cry for help in the hopes that someone will come to their aid, or tell them they love them.
I used to talk about it as a teen and in my early 20s. I was surprised by how much sense dying because I simply didn't want to live, made to me and I was shocked that society didn't accept it. I'd open conversations with people about how suicide should be available for everyone and doesn't necessarily have to do with mental illness. Some people just know they're not meant to be alive. In fact, my strongest depression and especially my anxiety came after wanting to die.
With time I felt it was cruel to expect family and friends to be my therapist and I stopped talking about it. Over time my perspective changed and I've come to believe the notion that our family and friends have to "be there for you" when you're mentally ill is foolish. I'm a kinder friend and relative if I accept that they may not want hear about suicide or be able to deal with and may be going through their own problems.