because it's programmed to.
You could program a robot to be able to identify itself in a mirror and then test itself to make sure it's not a painting by waving it's arm and comparing that to the image. that's exactly what we do.
Its still not self aware the key being it was "programmed" - its just following a set of rigid logic.