Just say you already committed to company B's offer. Any professional person should understand not being all wishy-washy by saying yes, then no, but maybe yes again.
It sounds like you decided to accept the offer, then informed your employer about it before sending the message of acceptance. You could have, and should have just sent the message of acceptance first. Remember, you're not asking for their permission.
You already informed them you got an offer before accepting it which was way more than you were obligated to do in the first place. Then you had a conversation and they made their decision. It's not like you went over their head or were even secretive about it. You told them what was up, they made their decision, and then you made your decision based on their decision.