How diodes protect H-bridge DC motor driver?
The diodes in this application are not there to block current, but to allow a low-impedance path for the coils to discharge themselves through. If such a path is not provided, then when the coil's supply is stopped at each cycle, the stored magnetic energy must find a path for discharge. This results in the coil expressing an arbitrarily high reverse voltage across its ends till the energy finds a way to get out. 

Result: This high voltage shows up across the MOSFETs, which die a miserable death. 

The diodes thus provide a short-circuit discharge path, dissipating this energy as heat within the diode. 

The capacitor's function is to act as a local energy store, to provide some of the energy required by the motor during the initial spike of each turn-on, and storing back some of the energy that kicks back onto the power rail at each turn-off. Without the capacitor, the current spikes at each edge would completely need to be served by the supply rail. As any supply connection will have some resistance, these current spikes thus result in voltage dips on the supply rail.

In simple terms, the capacitor smooths out the spikes due to temporary power demand and temporary power surplus, as the coils are energized and de-energized.