Julie, I am so sorry you had to go through that! That must have been extremely scary. I hope your dog will recover nicely.
It's true that dogs can be unpredictable. It's difficult sometimes to really appreciate their point of view. You never know when they are going to think that they should take action, for whatever reason.
MarnaLou