In order for a sin to be mortal, three elements must be present:
- Grave Matter: The act itself must be seriously evil and immoral.
- Committed with Full Knowledge: The person must know that the sinful act is seriously evil and immoral at the time they commit the act.
- Committed with Deliberate Consent: The person must freely choose to commit the sinful act, and not be pressured into it or have it happen accidentally, etc.
Killing yourself is a seriously evil act, so element 1), Grave Matter, is satisfied.
If the person somehow doesn’t realize that killing themself is seriously evil and immoral - for example, if they never received any training from their parents, from their religion etc that suicide was wrong - then it may be that element 2) is missing, in which case the sin would be venial. It’s still a grave sin (Element 1 is met), but the person’s culpability for the act is lessened, the same way as a court might find someone guilty of a lesser crime of manslaughter rather than murder.
Likewise, if the person doesn’t freely consent to killing themself because they were under great emotional pressure or they were in a state of psychosis or they changed their mind at the last minute when it was too late to stop themself falling off the bridge, etc then element 3 might be missing in which case the sin would be venial. Again, the suicide is still a grave sin (Element 1 is met), but the person’s culpability for the act is lessened.
As you know, venial sins should be avoided because we always avoid all sin, but a venial sin does not totally sever the relationship with God and does not take the person out of a state of grace, thus it is more likely that a person who dies in a state of venial sin can be saved and not go to Hell (though they might go to Purgatory).
I hope this makes it more clear.