Gravity is considered a force because it behaves as a force within the framework of classical physics. In classical physics, gravity is described by Newton's law of universal gravitation, which states that every particle with mass attracts every other particle with mass through a force called gravitational force. This force depends on the masses of the objects and the distance between them.
However, with the development of Albert Einstein's general theory of relativity, our understanding of gravity evolved. According to general relativity, gravity is not described as a force in the traditional sense but rather as the curvature of space-time caused by the presence of mass and energy. Objects with mass and energy curve the fabric of space-time, and the motion of other objects is influenced by this curvature.
The reason why we still refer to gravity as a force in many contexts is due to the fact that the effects of gravity can be mathematically described as a force acting on objects. This description works well in the realm of classical physics and is still useful for many practical purposes.
In the framework of general relativity, gravity is not a fundamental force like electromagnetism or the strong and weak nuclear forces. Instead, it is a manifestation of the geometry of space-time. The curvature of space-time caused by mass and energy tells objects how to move, creating the appearance of a force. So, while gravity is fundamentally a curvature of space-time, we often continue to refer to it as a force for the sake of convenience and compatibility with classical physics.