It's important to understand a dog's incredible ability to smell because a sick and deceased person experiences changes in odor.
The same is true for dogs.
If a dog senses that a person is ill or near death, then they will likely showcase signs of comfort and care.
It's simply in their nature.