Backstabbers are part and parcel of life on earth. It is very painful because it is something more than the regular cheating or deception by known/unknown people. This is because the betrayal is done by those whom one trusted not to do that. One might as well get used to this and prepare accordingly to minimize damage as much as possible, though it is not an easy thing to do. Most don't like to talk about this as this does expose their vulnerabilities to someone else.
Some basic ingredients that make a trusted person to become a backstabber are unbridled ego/pride/greed, wanting to look good in sight of others, selfishness/self-pity, public humiliation of that person in front of peers and/or his own family members, vengeful, being trapped in blackmail/drugs/crime, etc.
Going through history we can find plenty of examples, starting even from Cain and Abel (of Adam and Eve), down the list of various rulers in history. Jesus had one, and even knew about it a bit in advance but still carried on. Closer home we have Indira Gandhi and Rajiv Gandhi. Even closer and personal are from amongst our own friends and relatives.
Most of the time we can't avoid as various situations and bondings and relationships come into play to prevent taking clear steps. We do have two ears and one mouth, so we should listen more and talk less. Personally, for me my best option is reading God's word, and be in tune to listen to the inner voice to be aware, prepare and be safe. He can and does warn you enough in advance. Of course, I realized this after getting rammed, so now it is a valuable experience.
We can always try to be wise and hope the backstabber did it because of mitigating circumstances and not out of malice. No matter what we can rise above the defeat and hurt and become wiser and stronger. That situation can also show who are real friends from the previously unknown status. We should also make sure we don't become paranoid and suspicious of everyone, because that is no good and make us into creatures of apathy.
What is worse than having a backstabber is becoming a backstabber ourselves, and that also can happen if we have those characteristics described above. That can hurt a lot of people who trust you and me.