The person may not definitively want to die, but may wake up one day and not care either way, so attempting is a roll of the dice.
It also may be down to what was available to them at the time. There’s a famous case study where a lot of women in the UK were dying by putting their heads in the oven and gassing themselves in the 1950s. The UK government changed the formulation of gas that was being piped to homes and the suicides stopped. If those women really were dead-set on suicide, they would have just chosen a different method.
What people who’ve never had extreme depression might not realize is that in those low moments it feels like you will always feel this way and it will never ever change. Then you wait an hour or so and the feeling passes. So a person may not feel suicidal 24 hours a day, only at specific moments. But in those low moments, the chances of suicide dramatically increase and as the UK case shows, accessibility to quick suicide methods makes a big difference.