The shape of small objects (like people and houses and mountains and small asteroids) are determined by their mechanical properties. You can take a rock and cut it into a particular shape and it will pretty much stay that way.

The larger the object, though, the stronger its gravitational field. Imagine that you want to build a really tall building. You have to make sure it has a really strong foundation, or the foundation will be crushed by the weight of the building and the building will fall. If there was anything really big sticking up on a planet or a star, gravity would pull it down.

If a planet was like a cube, the corners of the cube would be higher than the rest of the planet. Since planets and stars are so big, you cannot build a "foundation" strong enough to hold up those corners! Anything you built it out of would be too weak to hold them up. Gravity would eventually pull them down.

Even solid rock will flow like a liquid, although very slowly, if it is pulled by a very strong gravitational force for a very long time. Corners on a cubical planet or star would eventually just squish down.

Since gravity pulls toward the center of the planet or star, everything gets pulled down into a sphere. However, planets and stars are not really perfect spheres. They spin, so they bulge out a little around the equator.