how do we navigate space without knowing the position of everything? wouldn't the gravity affect the sattelite/ship? I tried looking for other questions but I couldn't find any. (if this is a duplicate, then I'm sorry, I just signed up, so I'm not sure what to search for)  
I was wondering, how do we navigate into deep space without knowing the position of everything in space? Doesn't all matter have a gravitational affect on all other matter, even if the affect is very small? so wouldn't that mean that to succecfully land a probe/ship/sattelite on an asteroid we would have to compute the velocity of the spacecraft based on all the positions of every star, planet, moon, and asteroid in the universe, as well as random particles?
please note: I am not very experienced in physics. I am in 9th grade and am currently taking algebra 2
 A: There are two key effects which help deal with this.
The first is that, were we to want to land precisely on a point on an asteroid, we would indeed need to account for every last bit of matter in the universe.  Fortunately, in most situations we don't mind being nanometers off.  In fact, we often don't mind being meters off.  With this in mind, we can calculate how much of an effect this unknown mass would have to have on us before we failed our objective.  It turns out that, for most missions we care about, the universe can be simplified dramatically.  Most often we will see:


*

*Model the Earth's gravitational pull

*Model the Earth and the sun

*Model the Earth sun and moon

*Model the Earth, sun, moon, and Jupiter


Obviously each mission is different, but generally speaking the effect of all other players is so miniscule that it doesn't have a large effect.
The second key to this is guidance.  We rarely send a probe careening through the solar system without the ability to accelerate slightly.  Over time, as we see that the probe is falling off course, we issue commands to tell it to burn fuel to get back on track.  One major challenge for spacecraft designers is to size the fuel containers required to do this.  Too much, and you waste a lot of money lobbing a heavy object into space.  Too little, and you can't do the corrections you need to go where you need to go.
A: 
I was wondering, how do we navigate into deep space without knowing the position of everything in space?

In so far as navigating spacecraft is concerned, we on Earth do know the positions of everything important in space to a fairly high degree of precision. How gravitation from remote stars affects satellites is not a concern, at least not for the short term (years to decades). While remote stars do have gravitational effects on the satellites orbiting the Earth and the probes sent to other planets, these effects are very small.
That said, most vehicles in space don't know where they are in space. (Most do know where they are pointing.) For example, the New Horizons spacecraft that flew past Pluto in July 2015 and then 2014 MU69 ("Ultima Thule") in January 2019 had no clue it was performing flybys. It instead was commanded to take pictures in terms of time, attitude (pointing), and attitude rate. Navigation of that spacecraft was performed on the Earth by NASA's Deep Space Network, which has sites with very large antennae in California, Spain, and Australia.
Thanks to instrumentation on deep space probes, the Deep Space Network can measure with extreme accuracy the distance between the Earth and the probes and the rate at which that distance is changing. Multiple such measurements spread over time coupled with knowledge of the orbits of gravitational bodies in the solar system enables people on the ground to accurately determine and predict the six degree of freedom (position and velocity) state of space vehicles.
There are many reasons spacecraft do not navigate themselves. One is that they don't need to; witness the success of New Horizons. Another reason is that space qualified computers are very expensive and very limited; a quarter of a million dollars for a computer with less processing power than a ten year old flip phone. Yet another reason is that the software for those computers is extremely expensive; by the time all the conceptual development, reviews, and testing are factored in, spacecraft software is written at the pace of about one line of code per person per day.
A: Well, when going to Mars it typically works like this:
Launch services deliver the bus to low-earth-orbit (LEO) for a once-around. Then the spacecraft (s/c) is launched on a course to Mars.
"Cruise" takes over at his point. They rely heavily the Nav[igation] team. Of course these guys have a pretty good idea what the gravity field is between here and Mars, but they still need telemetry-correction-maneuvers (TCMs). There are 3 scheduled TCM outbound from Earth (1-3), and 3 more (4-6) on the Mars end.
Nav uses delta-DORS to figure out where the s/c is. This is like the old LORAN system used by ships, except instead of using manmade radio transmitters placed around the globe to triangulate a position, it uses natural radio transmitters: quasars powered by black holes (this is the only know engineering application of black holes at this time). The signals' times are compared with super accurate Earth signals to compute the s/c position in the JPL barycentric coordinates system (BCS). Mars is usually a direct transfer orbit, though it can be done with a Venus flyby. Flyby's, esp. for the gas giants, require post-Newtonian or post-post-Newtonian corrections for relativistic effects.
TCM's hone in on the correct trajectory, usually with only 2--the 3rd is for margin.
Nav tracks the s/c's position during cruise. Outgassing, solar radiation pressure, and asymmetric thermal emissions are bigger effects than gravity-field uncertainty.
A few days before entry, TCM 4 tunes up the trajectory, with TCM 6 scheduled for 4 hours before entry. E -4h is the last time anyone commands the s/c, and it is a big deal to do anything out of the ordinary (like a major TCM, or a flight software new-parameter up-load).
At this point Nav really knows where the s/c is, and the deliver it to an imaginary plane called the "b-plane" for some reason. It is about 1 square km, and all they tell Entry-Descent-Landing (EDL) is that it will go through that plane somewhere within a 1 second time window.
At this point, the greatest uncertainty is "Where is Mars"--the planet's position is far less well known than the s/c's. Moreover, inertial guidance cannot track the 10g aerobraking and violent supersonic parachute deploy to better than a fraction of a km. Hence, on board terminal descent sensors (radar, maybe lidar someday), figure out where the surface is and how fast it is moving. Touch down velocity requirements can be in the cm/s range, so that the rotational speed of the surface over a 100 km landing ellipse has a much large spread than that.
In summary, gravity-field uncertainty is far from the top of the list of concerns.
