The diodes across the relay coils are called kickback diodes.
When the relays are de-energized, they produce a high voltage spike.
The diodes absorb the kickback spike.
The diodes on either side of the motor do similar as the motor also produce kickback spikes.
Make sure you use the normally closed contacts on the limit switches.
To move the motor, one transistor will be ON at a time.
The limit switches are there to stop the motor when it reaches a maximum point, i.e. up/down or left/right.
