If your intentions are to make peace, then it’s good to speak up. You might ask friend B why they let friend A talk to them like that. They may say it doesn’t bother them, or they may be thankful that you will help them stand up to and stop the bully.
If your intention is that you enjoy a good fight, then keeping out of it is probably best. Making peace is better than making war.