How come I have random depression and random suicidal thoughts and feeling?

Talk to a therapist. Or psychologist to figure this out. Suicidal thoughts and feelings are serious & should not be ignored. Why these thoughts & feelings are happening cannot be answered here. Talk to a mental health professional right away.