Gravity acts equally in all directions
Because of gravity. Planets and suns formed because matter clumped together: cosmic dust and chunks attracted each other, forming clumps, and the larger the clumps grew, the greater their respective gravitational pulls. And because gravity acts equally in all directions, the sphere is the shape where gravitational forces are in balance.
A comparison to illustrate this: Something exciting suddenly happens in a large square in a city. An acrobatic group is building up. This attraction now “attracts” the audience. What is happening? The first viewers wrestle in a first row close to the show. Everyone who streams in tries to get as close as possible. They successively form a second ring, a third, and so on. If the space is open to the public, meaning there are no obstacles in the way, the crowd will be quite circular. If the wreath were a little thinner at one point, i.e. if there were a gap in the row, it would be closed quickly – because someone would notice that there was a free space where you could see better and would go there. So you can say: The attraction in the middle of the square exerts an “attraction” that has a balancing effect right down to the last row.
The gravitational pull of a planet works in exactly the same way – only that what is happening takes place in three-dimensional space. A sphere is formed instead of the circle. The balancing effect described is the greater, the more mass the planet has. Because the stronger the gravitational force is.
Small celestial bodies are more like potatoes
Small celestial bodies like asteroids can be quite irregular, often resembling a potato more than a sphere. In contrast, the large planets Jupiter, Saturn, Uranus, Neptune have an almost perfect spherical shape.
Earth is not a perfect sphere
The earth is also very similar to a sphere. But if you measure exactly, there are not only mountains on the surface, but there are bumps and bumps even in the earth’s gravitational field. This is mainly due to the fact that there is a lot going on inside the earth. There are hotter and cooler currents in the Earth’s interior, that’s why the Gravity varies from place to place, and of course this also has an effect on the surface. That is why the sea level is not the same everywhere.
The second caveat is: Earth is somewhat flattened at the poles. This in turn comes from the self-rotation: Because the earth is constantly rotating, centrifugal force causes the earth to be a bit thicker at the equator.