Not everyone is lucky enough to be brought up in a stable and loving family environment, and bad experiences during childhood can increase the risk of developing depression. However there are plenty of people who suffer from depression who had great childhoods, and plenty who had a tough time in childhood who don’t get depressed. Depression is usually the result of a combination of factors.
There’s always a possibility that depression could be genetic, and there does seem to be an increase in risk of depression where other family members have experienced it. But just because a family member has had depression at some stage, doesn’t mean that you will too.