It was in the heat of the moment, his friend challenged him and he responded. If he had to do it again maybe you're right. But then again maybe he was pissed at his teammate for throwing at his friend's head too. Seems to me that was in play by the way he responded to Machado.
But as I said this entire throwing at batters thing is so stupid, I've always felt that way. "That's the way it's always been" is not a good reason to keep doing stupid, dangerous stuff. And throwing at batters to get back at them, often for just hitting a home run or after a teammate unintentionally hit a batter, is juvenile and just leads to bigger problems. It doesn't "protect" teammates, it just puts them in the line of fire for the next retaliation.