This is a nice article that helps to explain why sometimes we see a normally calm and gentle dog nip or snap at a dog or person. Note this isn't about causes like undiagnosed pain, or resource guarding behaviour that is gradually developing... just about those totally out of place nips most of us will see at some point (hopefully with no harm done).
http://positively.com/contributors/the-perfect-storm/
http://positively.com/contributors/the-perfect-storm/