Older people who often take their dogs out for a walk are more likely to lead longer and healthier lives, a study has revealed.