An elderly lady holding a scruffy dog and smiling contently.
a woman holding her scruffy dog
If a woman is holding a scruffy dog and smiling contently, she is most likely holder "her" scruffy dog.
Both sentences share a common subject (lady, woman), verb (holding), and direct object (dog).
A lady is a woman.