(I am referring to the baby in this piece as "it" to avoid the he/she binary, but hoping not to offend anyone reading it who doesn't have that concern)..
Every one of us comes from a primary group, be it a family or an institution or foster home, etc. We have experiences in our young lives that teach us about relationships, the primary source of life. For the moment I will use the relationship to the mother, though that is clearly not the only possible source of early attachment, to explain further.
Now, imagine a mother who is attuned to the baby. She senses when the baby needs stimulation, when it needs to be left to its own reveries, when it needs changing or feeding. She engages with the baby, laughing or smiling when it laughs or smiles and making sounds in response to its' sounds. The baby develops a sense of the world and the people close to it as safe. This baby will likely have a secure attachment and will carry a trusting feeling in relationships forward to adult relationships.
Now imagine a mother who has perhaps suffered from severe postpartum depression that has never lifted. She is dragging herself through the day, feeling sad or completely shut down. Her interactions with her baby will be very different. She will likely be preoccupied with her own depressed thoughts and feelings, making it very hard to attune to the baby. She may even not feel like holding the baby or be very inconsistent in her responses to it. This baby learns that it can't rely on the mother for consistent care and will develop an insecure attachment, likely of an anxious type. This will be a factor in how it functions in adult relationships.
Couples therapy can help couples to understand and have empathy for each other's attachment style, which, if not understood, can often lead to problems. It doesn't mean it will be easy, but it can go far in helping each other not to take it personally when their partner behaves in ways that don't feel good or make sense to them. Of course, individual therapy is another excellent way to explore, understand and manage this aspect of yourself.