Recently, I finished gravitation. I wonder why the shapes of planets or any body revolving around any star are not cubical or ellipsoidal. In our solar system all the planets are spherical in shape. Why isn't a body of any other shape found revolving around the gravitational field of any star?
All massive bodies are ~spherical in shape due to their own gravity, not because they orbit around a star or a galaxy center.Gravity works inwards from all directions, towards center of mass, causing the bodies to become spherical. These bodies are not only planets, but also stars themselves.
There can be smaller (less massive) bodies that can be in different shapes because they have less gravity and their material can withstand their gravity in that shape. Massive bodies have higher gravity and the only stable shape in that case is spherical.
Every material would have some shearing stress limit (there are no true rigid bodies). Considering this, if sufficient material accumulates together in a small region, it would cause the material to collapse into a spherical shape due to its own gravitational force (the shape of lowest potential energy).
Accordingly, if the material were extremely hard or less in quantity (e.g. asteroids), the body may not be spherical.