Here's why:
* Lack of Atmosphere: Both Mercury and the Moon have very thin or nonexistent atmospheres. This means there is no protection from incoming objects like asteroids or comets.
* Early Solar System: The early solar system was a very chaotic place with many more asteroids and comets flying around.
* Evidence: The craters show the characteristic shapes and features of impact events.
While other geological processes like volcanic activity can also create depressions, the sheer size and distribution of the craters on Mercury and the Moon strongly suggest impacts as the primary cause.