Since the reactions occur as a consequence of the difference in electron density within a molecule, the reacting molecules must collide in the precise places and with a very specific orientation.
An effective collision between two molecules, in the appropriate regions and with the correct orientation, gives rise to a reaction and the reactive molecules are transformed into new ones (products).
The location of the electrons in the molecules marks the place and direction of the attack.
The same molecule can undergo different reactions. Everything will depend on the place and direction of the approach of the attacking species.
This scheme is certainly complicated, as Chemistry sometimes is!
If you don't fully understand it, don't you worry. You'll do it later. That's for sure!
RO- type ions (R = H, CH3, etc.) are very good nucleophiles but they are also strong bases. If they collide with an electron-deficient carbon they act as nucleophiles.
If they collide with a hydrogen, they can take it away and thus act as a base.
It all depends on the way the molecules approach.
Depending on the orientation of the attack, the same molecule can take different reaction paths.
It is as if the molecule were at a crossroads and took one direction or another depending on the attacking "bus" and the direction of the latter