Yes, it is true that people who commit suicide have mental health problems. Most people that commit suicide usually are depressed. It mostly starts from overthinking a negative part of someone's life, it progresses to depression, suicide ideation, it gets to suicide attempts, if not noticed, these attempts can eventually lead to suicide. So, it is true that mental health problem can lead to depression.
It is likely that those who have committed suicide are suffering from a form of mental illness. Most people who take their own lives are depressed. They feel that they cannot do anything to change their lives anymore. They do not know what else to do and they see death as the only solution to their problems. Take note though that not all people who commit suicide are mentally ill.
There are also some people who are fascinated with death and they cannot wait long enough for death to actually take them. With proper treatment and the support of people around them, those who are suffering from mental illness would be able to recover from what they are going through.