It is natural for some friendships to end and it is unrealistic to expect that you will hold onto every friendship that you make in your life. Some friendships last longer than others because there are deep emotional bonds, you have shared life events (happy ones like birthdays and graduations, and sad ones like divorces and funerals) and many common interests and the times that you get together feel natural and unforced. Like any relationship, friendships do take effort on both sides to maintain, and it should not feel like a hostage situation, where someone (or both of you) resents spending time together. If you were able to notice warning signs that your friend was thinking of "breaking up" with you, you could decide whether you both want to try to resolve the issue or whether to end the friendship.
Some friends outgrow each other, some friends drift apart, some friends betray the other's trust or have a big argument that cannot be resolved, some friends are encouraged by other people in their life to end the friendship. The best way to find out why a particular friend is "breaking up" with you is to ask and hope that the friend is willing and able to talk about it. If you are too emotional at the moment to ask, just take a breath and revisit the conversation when you are calmer, because, when you are upset, it is difficult to really hear the reasons the friend has for wanting to break up with you and consider those reasons with a rational mind.
If the friendship does end, then it is important to look at how you are handling the loss of this friendship. Are you taking a long time to grieve the loss of the friendship? Are you beating yourself up and thinking negatively about yourself ("I must be a terrible friend," or "I will never have another friendship like that") or feeling ashamed for losing the friendship? Are you anxious about losing other friendships and becoming more clingy in those relationships? Are you rushing to make a new friend ASAP, in order to replace that ex-friend? Are you withdrawing from other friendships or avoiding making new friends because you don't want to risk more pain? Are you calling or texting the ex-friend to apologize and ask to get back together? Are you replaying memories in your mind and trying to figure out "what went wrong"? These types of responses can be emotionally and mentally draining on you, can affect your ability to concentrate and your physical wellbeing, and you might feel better if you talk to a professional to sort this all out. Talking to an objective person (not venting to other friends or family about the breakup) can help you to cope, learn and grow from this experience without negatively impacting other relationships in your life.
For more of my comments on this topic and to find out some common warning signs that your friend is thinking of "breaking up" with you, check out this recent Bustle article: https://www.bustle.com/p/7-signs-your-friend-is-trying-to-break-up-with-you-8918411