How to determine the correct polarity of the diode
Your first drawing shows the polarity of the voltage across the diode when the top terminal of the transformer is positive, and diodes D3 and D4 are reverse biased, and not conducting.

D1 and D2 will have anode positive, and be conducting - they are apparently ideal diodes as they are shown with zero volts across them.

When the top terminal of the trasnformer is negative, D3 and D4 will have the anodes positive, and will be conducting, while D1 and D2 will be reverse biased, and not conducting.

The diode polarities in that drawing are the actual voltages applied to the diodes, not some innate properties of the diode.