The theory you mentioned, proposing that Earth is a giant asteroid that got caught by the Sun's gravity, is not a widely accepted scientific theory. The formation of Earth and the other planets in our solar system is better explained by the prevailing scientific model called the nebular hypothesis.
According to the nebular hypothesis, about 4.6 billion years ago, a giant cloud of gas and dust known as the solar nebula collapsed under its own gravity. As the cloud contracted, it began to spin and flatten into a rotating disk. Most of the material in the center of the disk eventually formed the Sun, while the remaining material in the outer regions of the disk coalesced to form planets, including Earth.
In this model, Earth's formation was a result of the accumulation of dust and gas particles within the protoplanetary disk. Over time, these particles collided and stuck together, gradually growing in size to form planetesimals, which later merged to form planets. Earth, like other planets, was not an independent object captured by the Sun's gravity but rather a product of the accretion process within the protoplanetary disk.
Regarding Earth's orbit and the Sun's gravitational pull, it's important to understand that the motion of objects in space is governed by the gravitational forces acting upon them. In the case of Earth, it is in a stable orbit around the Sun due to a balance between its forward motion (tangential velocity) and the gravitational force pulling it inward.
As Earth moves in its orbit, it experiences the gravitational pull of the Sun, which continually alters its direction but does not cause it to spiral into the Sun or escape into space. This is because Earth possesses sufficient tangential velocity to maintain its orbital path. The gravitational force from the Sun provides the centripetal force needed to keep Earth in a relatively stable orbit, following an elliptical path around the Sun.
In summary, the prevailing scientific understanding is that Earth formed within the protoplanetary disk as part of the natural processes of planetary formation. Its stable orbit around the Sun is a result of the balance between its gravitational attraction to the Sun and its tangential velocity, which allows it to maintain a relatively stable path without spiraling into the Sun.