We know that matter has mass. Masses attract other masses with gravitational force. This force is evident for huge bodies like planets and moons.
The particles of the planet on the surface are attracted and pulled in (towards the center) by the gravitational force of the planet. Thus the gravitational force tries to minimize the size of the planet. As the gravitational force is symmetric in space in all directions, the soil/masses of the planet settles down to spherical shape.
Also the gravitational force causes the planet to take the shape with lowest volume and highest surface area. That is the surface.
Also planets/moons rotate about themselves and/or about the Sun. When they rotate due to the centripetal / centrifugal force or inertia, there is a tendency of movement of excess heights like hills , to become lower in height to become flatter. over a long duration the surface of planets becomes smoother, with the same radius all over.