Grandparents who regularly care for their grandchildren are at a reduced risk of dementia, according to new research.