Why does the multimeter need to be set to AC voltage to measure the voltage on secondary winding when driven by a square wave on the primary?
The output of a transformer is always AC.  In the long run, the average current thru a transformer secondary with resistive load is always 0.

For example, consider driving the primary with a 0-10 V pulse train that is low for 9 &micro;s and high for 1 &micro;s.  The DC level is 1 V going into the primary.  However, that 1 V will be lost coming out of the secondary.  The open-circuit voltage you get out is -1 V for 9 &micro;s and +9 V for 1 &micro;s, multiplied by the turns ratio.  If the primary has 100 turns and the secondary 300, then you will get -3 V and +27 V, for example.

A good meter set to DC will always show this as 0 V.

Different AC voltmeters will show you different voltages for the -1 to +9 V example pulse waveform.  That is because most meters don't read true RMS.  Most will measure the average of the absolute value, then apply the correction factor from that to RMS for a sine wave.  That correction factor will be incorrect for something like the pulse train in this example.

To get the voltage of non-sinusoid waveforms, you either have to get a true RMS meter, and make sure your signal is within its frequency range, or use a scope and do the math yourself.  Some scopes have RMS measurement built-in as a math function, which makes them in effect true RMS meters.  Again, keep the limitations of the RMS meter in mind.