Stuff like this is a combination of genetics and upbringing. Your genes may make you more prone to certain types of mental illness, but they will only be activated in response to environmental factors, like traumatic events. Once you've developed some type of mental illness, there are risk factors which may make things worse and resilience factors which may make things better in the long run. Resilience factors which may alleviate your symptoms include social support, therapy, medication, exercise, psychoeducation, proper sleep, self-confidence and self-efficacy.