The association of early life factors with depression and anxiety in adults aged 40–69 years: a population-based cohort study