We can view this in two ways: First, that mental illness is clearly an important risk factor. But also, that half of all suicides are due to other factors. Mental illness is not the only risk factor and explanation!
A common method for estimating the prevalence of diagnoses is through psychological autopsy, but some researchers suggest that these numbers, Psychological autopsy studies estimate the rate of psychiatric disorders in suicides to be around 90%, are inflated due to post-hoc reasoning and assumed, not verified, diagnoses.