Simply, attachment is the emotional bond (connectedness) that babies need to form with their main caregiver (usually the mother) in order to develop a sense of security, which is necessary for their emotional and social wellbeing.
According to the theory of attachment (which was developed by John Bowlby in the late 1960s and furthered by Mary Ainsworth in the early 1970s) the survival of humans is best ensured/guaranteed when closeness to an attachment figure is maintained. So, (as primary caregiver) the mother's availability and her consistent responsiveness and sensitivity to her baby's needs (e.g. when the baby cries the mother responds to the baby in a warm and loving manner), the baby learns that the mother is dependable, providing a feeling of security. These constant and predictable interactions ensure the infant's protection, and in times of stress the infant seeks the mother as a source of comfort. The development of this secure attachment fulfils Baby's emotional needs.
From having such a secure and dependable relationship with the main caregiver a baby is likely to begin developing a sense of confidence and autonomy (independence), enabling her to explore and learn about her surroundings, and continually fulfilling her growing curiosities.
Note: Research involving infants at 3 months of age whose mothers (as primary caregivers) are sensitive and responsive, are more alert/interested and active than infants whose mothers are less sensitive and responsive.
Is it only a mother that a baby becomes attached to?
Firstly, attachment has nothing to do with genetics, i.e. whether you are the baby's biological or non-biological parent. Baby becomes attached to the person who is the main provider of sensitivity and understanding of his needs. If the dad is the primary caregiver then 'in theory' it is he who the baby will learn to seek as the main attachment figure in times of emotional need, providing he is consistently responsive and sensitive to the baby. If the mum and dad equally share the parenting role, the baby will learn that there are two people equally sensitive and dependable. Besides Mum and/or Dad, as Baby develops she may learn there are other people in her life that are dependable, providing her with a loving and secure environment e.g. Grandparents.