Ouamuamua was just drifting along and its orbit around the galactic center just happened to intersect the sun's orbit. However, the sun's gravity did affect it as it "fell in" and it picked up speed. It then passed through the inner solar system, losing speed as it pulled away into extragalactic space. but not enough to get dragged back.
Apparently, this object experienced a little additional acceleration, presumably from some gas venting (or maybe a Dean Drive? 8) ) that was detected as its orbit was plotted on the way out.
Still, we must keep in mind that theoretically, every atom of matter attracts every other particle in the universe, but because of inverse square law, the force of attraction becomes negligible at great distances. So it is wrong to think of the sun's gravity as hoovering the surrounding space, sucking up all loose debris.
Space/Science » in reply to Just to be clear
You're correct. This was a random encounter.
