They suppress the inductive transients from the motor to protect the L298 transistors.
If you look at their polarity, you will seed that all the diodes are reverse biased expect for transients below ground or above the power supply voltage, so have no effect on the normal drive voltages.