I have asked a professor if he were available for being my graduate thesis advisor, now my bachelor thesis advisor is angry with me A couple days ago I was asked by my former bachelor degree advisor (let's call him X for short) if I were interested in doing a MD thesis with him. I have replied him that I wasn't sure yet about what I would like to do for my MD thesis and I told him I would have asked some other professor before deciding. He said he was perfectly okay with that.

I have therefore talked to several professor and, among them, to an ex collaborator of X, let's call him Y, who works in a different country.
In the mail I wrote to Y, I did not put X in cc nor I have mentioned him.

Y replied to me, putting X in cc, and suggesting that I should ask him if he were available to be my internal advisor first.

Finally, X sent a mail to Y, with me and a friend of mine (who wrote the mail to Y with me, as he were interested too) where he said I was trying to "outmaneuver" him by writing directly to Y. He also reported a mail written before I wrote to Y where, among other personal opinions on me, he suggested I was a mental instable person and that I push around my girlfriend (X was the bachelor thesis advisor to my girlfriend as well).

Now, of course the reaction of my professor is beyond any acceptable boundary, but what I really want to know is whether I am wrong at all. Should I have asked him before writing to Y?

Also, how should I reply to X?

Beg your pardon for the Xs and Ys...
It sounds like you've found out the reason that Y is no longer a collaborator of X.  Furthermore, you should thank your lucky stars that you found out now, before you committed to working with X.

Assuming there are no important missing pieces in what you report, the situation is pretty straight-forward: you were entirely reasonable in telling X that you wanted to talk to some other professors before deciding, and it is entirely reasonable for you to contact Y without reference to X (X has no claim over you and your interactions).

The email that you report X having sent is absolutely inappropriate, and also clearly disingenuous: if X thinks so badly of you, why would X have invited you to work for them?  It seems clear that X is wanting to control you, and so you should definitely NOT work for X.  

At this point, I would recommend writing an email to X, stating that you found the email both highly inappropriate and also confusing, particularly given that X was also asking you to work for him.  State that because you find this inappropriate, you are no longer considering working for X.  It is very important that this interaction be in email, and that after this point you restrict interaction to email, since X has proven to be manipulative and untrustworthy and you need a written record with which to defend yourself if necessary.  I would also recommend continuing communication with Y, if this is possible despite the attempt of X to sabotage you.