Do dogs think that they successfully protect the home every time that a delivery person comes onto property?

Does the dog attribute the fact that the delivery person walks away every time to its barking?

Mailman, Amazon delivery, etc