This is simplistic and wrong.
Mental illness is a factor in some attempted or completed suicides.
But is mental ill health the only factor? No. There are many things that contribute to someone attempting suicide. Significant factors include debt, relationship breakdown, recent release from a MH hospital, previous attempts at suicide, a relative who completed suicide, etc.
Many people have mental ill health, and not all of them kill themselves. The difference between the people who try suicide and those who don't is not severity of illness, but severity of other pressures.