I replied in comment:
"We learn it, slowly, not by looking at others and how they treat us but by looking at the God who died for His enemies (you and I and everybody else). The more we realize we were His enemies, and even still do and love things that only enemies would love, and yet He loved us like that, the more we learn to love our enemies. Takes a long time.
But it is impossible to love people so long as we are entirely focused on what they have taken from us or how they don't give us what we want or threaten it.
Loving people who hurt us is always costly and often painful. Look what it cost Jesus."
The short answer is: we learn love from God. It flows from God to us, and we choose to give it to others. The more we receive and apprehend God's love in the face of the depth of our depravity, the more compassion and love we have on others, even when they have hurt us.
The thing about love is that it always costs something. There is always a place you come to where, in order to love and/or forgive someone, you are forced to let something go. Why? Because, as I alluded to in my comment, the reasons we do not love others are related to things we love more than others. There are things we are holding on to, or trying to hold on to, things we have enthroned in our lives, desires that capture our hearts. It is easy to love someone who never hurt you. But when someone has destroyed your reputation, killed your dream, or taken some other thing you lust after and love more than others, you have a choice: you can let go of that thing you are holding on to, relinquishing your dependence on it and right over it and love the other person, or you can hold on to it and hate them.
Like walking in faith, love takes us places. At each destination, at each bump along the road, love for God and others asks us, "What or who do you really love? What is most precious to you?" Often times, we find out that what we love most is not God and our neighbor (or our enemies, as Jesus commanded). We find that we love our reputation, our money, the glory we get from the approval of others, our family, our agenda, our plans, the respect we think we deserve for our good efforts, or our dream for our dream life more than we love others. They are usually good things we love, but we love them too much. They become what the New Testament calls "lusts." In other words, we have a hard time loving others because we are driven by self-interet. We love something they are blocking from us, and it's all about us and what we want.
When you have a hard time loving someone who has hurt you, you must ask yourself, "What is it that I want so badly that they are blocking or have blocked from me getting?" That is why you won't love them... that is why you can't love them. You can't because you're ruled by another master, and you remain focused on you and what you lost. Love is costly (just look at Jesus) because it always forces us to restructure our priorities and dethrone the things we hold as so precious, forcing us to humbly look to God, endure the debt of what we lost, and love and serve even those who hurt us.
And it does... it takes a long time to learn. But as we learn it, we find freedom from the chains of our own desires that hold us down. We don't cease to desire, but our desires for self begin to subordinate themselves to the love of God and our desire to glorify Him by loving and serving others. We see beauty in Jesus and what He did for us, and it begins to surpass our desires for self.
Real life has an uncanny way of providing practical examples to this :). Recently, my son got himself into a whole lot of trouble. At first, I was somewhat in shock. But anger soon grew inside, and it was eclipsing my God-given responsibility to love him as his dad. Why was I angry? It was because his actions blocked from me what I wanted. I wanted all of my efforts to love him, listen to him, pray for him, teach him, and raise him well to pay off. I wanted my payoff, I wanted the results I expected -I demanded them, and he urinated on all of them. Suddenly, it was all about me. I was being selfish. At this crossroads, I had to let go of my expectations, to demote them, to let go of the strings I had attached to all of my giving. I could not, and cannot, really love him and serve him otherwise.
Real love brings us to a crossroads, leading us, if we wish to walk in the way of love, to demote self and demote our self-interest, our self-kingdom, our self-plans in order to serve another. Real love is a life-long process of dethroning and surrendering all of the things we love more than God and others.