How does a chemical "know" which other species are present and where equilibrium is?
What we got here is a dynamic equilibrium, not a static one. For a static one the molecules would need to know when to stop reacting or when to react in a certain way, in a dynamic equilibrium you don't need to know.

Here's a ELI5 explanation of what's happening:


  Let's say you've got a garden with an appletree and hundred of apples
  are on the ground. You don't want them there so you throw them to your
  neighbor. he's an old man and doesn't want them either, so he throws
  them back. You are much faster than him and there are hundreds of
  apples around you, so you don't even need to move to throw them and
  you can throw them very fast. He on the other hand has only a few
  apples laying around and has to move quite far, so he's throwing them
  back much slower. But what happens after time? 
  
  Well, there will be a point where there are more apples on the old
  mans side than on yours, so you have to run a lot to get to those
  apples while the old man has to move only some steps to reach a new
  apple. Eventually it will level out and both of you will throw apples
  at the same rate. That's a dynamic equilibrium. Because there are more
  apples on the old mans side he can throw them back as fast as you can
  throw them to him, even if you are faster.


Now here the chemical explanation:

Reaction rates are dependent on the concentration. High concentration equals fast reaction, low concentration equals slow reaction. At the beginning you got only starting material, it will react fast to the product. The product will react back but there is extremly low concentration so it's slow. But after some time you will reach a point where the concentration of the starting material is so low that the reaction is so slow, that it matches the speed of the back reaction which got faster because you got more and more product. At that time there will equal amounts react in both directions, making it look like the reaction is standing still.

For example: If we got the reaction $\ce{A + B \rightleftharpoons C + D}$ and the reaction rate of the forward reaction is $r_1=k_1[A][B]$ and the backwards rate is $r_2=k_2[C][D]$ then we will reach an equilibrium $r_1=r_2$ and that's the case if $k_1[A][B]=k_2[C][D]$.