It is possible to mistake attachment for loving-kindness and compassion. Love and compassion are distinguished from attachment in that they apply equally to your friends and your enemies. Genuine love and compassion make no distinction based on your relationship to the object of compassion. They are the wish that all sentient beings without exception have happiness and the causes of happiness, and the wish that all sentient beings without exception be free of suffering and the causes of suffering. The keynote of those two attitudes is that there is no hope involved of any kind of return or any sort of personal satisfaction as a result of the happiness of others.
In the case of attachment to someone, you wish that person well but it is based on an identification with him or her as “my friend, my son, my daughter.” This identification and this feeling of ownership or territoriality is related to wanting some kind of return. You enjoy the happiness of that person because you have identified with him or her, and therefore in essence it is just wishing for your own benefit. Such attachment can very easily turn to aversion, anger, and hatred. That is the difference between compassion and attachment.
From The Instructions of Gampopa: A Precious Garland of the Supreme Path, by Khenpo Karthar Rinpoche, page 82