As Larry the cat welcomes yet another prime minister, an expert explains how pets adapt to change