This longstanding question is known in psychology as the nature versus nurture debate. It seeks to understand how our personalities and traits are the product of our genetic makeup and biological factors, and how they are shaped by our environment, including our guardians, peers, and culture.
See this explains that the nature versus nurture debate, which looks at how much of who we are comes from genetics and biology (nature) and how much comes from our environment and experiences (nurture). It helps us understand why people develop different personalities and traits.