How does flyback converter with two MOSFETs work?
When switches are off, magnetizing inductance provides magnetizing
  current that enters primary windings of the transformer through the
  dotted side


Incorrect. When the switches are off, the current doesn't reverse it ramps down from the previous "charging" positive value to zero. This means that the voltage at the lower MOSFET drain reverses polarity compared with the upper MOSFET's source.

The two diodes steer any excess back-emf to the DC power rail on the primary side. This steering is necessary to prevent leakage inductance on the primary damaging the MOSFETs because the energy contained in leakage inductance is never transferable to the secondary. 

Here is my version of your circuit showing the charging voltages in red followed by the energy transfer voltages in blue: -



It's the primary voltage that reverses because the previously positive ramping-up current when the MOSFETs were on (red phase) becomes a negative ramping-down current during the blue phase.