Coupled inductors in flyback
How does the primary inductor voltage reverses in attempt to keep
ampere turns constant and at the same time it keeps its polarity
positive in the equation

We're talking here about the red waveform in the picture below.

The area of voltage•seconds above the \$V_{BUS}\$ level equals the area below \$V_{BUS}\$. That ensures that the coupled inductor (aka transformer) behaves correctly.

It is said to &quot;reverse&quot; but another way to look at it is to see that the secondary voltage produced when the MOSFET deactivates becomes transformer-coupled back to the open-circuit primary by \$N•V_{OUT}\$.



Image source.
What is meant by the voltage reversing is that the non-dotted end has \$-V_{BUS}\$ applied when the MOSFET is activated and, that voltage reverses to a \$+N•V_{OUT}\$ level when the MOSFET deactivates. To fully understand this you have to regard \$V_{BUS}\$ as the voltage reference point.
If instead of the above circuit we used a high side MOSFET to control the transformer primary (dot to 0 volts) then, during MOSFET activation, the undotted primary would reach \$V_{BUS}\$ and, during MOSFET deactivation it would go to \$-N•V_{OUT}\$. Maybe that's easier to see?