Unexpected Danger: A peripheral concern not directly related to the power supply operation as a power supply BUT still relevant.
Damage CAN be caused by connecting a power supply to equipment in selected and relatively uncommon cases, and it may be safer to connect the supply to the target device first, as you were advised. Because ...
"Properly designed" power supplies will have 2 x "Y" noise filter capacitors, required by regulations - one from each input mains leg to ground.
The input ground may be connected to output ground - usually negative.
IF the input has a 3 pin connection - 2 mains voltage wires (phase & neutral) + ground AND a 3 wire cord AND a 3 pin plug AND the socket ground pin is grounded, then all is well. However, if the ground circuit is incomplete anywhere between the common point of the 2 Y capacitors and system ground then the centre point of the 2 Y capacitors will be at 1/2 supply voltage when unloaded. This voltage is connected to output negative and the laptop ground will be at 1/2 supply with capacitive coupling to mains. The capacitors are usually 2 x 0.001 uF or thereabouts (AFAIR) and the available current is below that considered to be required to cause fatal or even "dangerous" electric shock. It is however enough to cause extremely annoying or even somewhat painful shocks. This may be felt as mild annoyance when brushing exposed metal work with fingers or other bare skin. A laptop used on your lap may be too annoying to use.
In some cases the combination of voltage and available current can be enough to cause equipment damage. I have (long ago) had a new printer functionally destroyed when a printer cable was connected between it and a PC. The PC was grounded and the printer apparently was not.
In such a case it is arguably (and not certainly) better to have the power supply plugged into the target equipment before mains is connected. This matches the sequence you were told is best - but probably not for the correct reason.
Best of all is to ensure the power supply has a 3 wire properly grounded mains lead if y capacitors are fitted and if ground is continuous from input to output.
Note that the target device (here laptop) is not usually intentionally grounded (unlike the printer - PC example above) and connecting a 1/2 mains voltage capacitively coupled ground to a floating laptop "ground" will probably not cause damage. Problems may occur when an informal ground path exists between the laptop and true ground - this may be users, who will receive minor shocks, or may be a hard grounded other item of equipment - and damage may then occur to the laptop - regardless of connection order. This is by no means certain and often will not be a problem. Again - best course is to ensure a proper power supply ground when needed.
Why would the order matter, you'd end up with a laptop at half of the
mains voltage in either case. If that's sufficient to do damage, you
will get damage. – jms
One way you have a preconnected system which is then raised to half mains voltage (or less) by a high impedance connection. The other way you apply a source at half mains voltage to the "target device" - it is relatively high impedance but can have energy stored in the capacitors and it has significant damage potential. Experience shows that in some cases damage does occur.
When the power supply is first connected to the target device (laptop etc) and then connected to the mains you have a system at equilibrium with the y-capacitor's midpoint which then rises to high impedance half mains voltage modified by whatever load the target may place on the voltage.
If mains are connected first you have 2 x Y caps charged to Vmains/2 (actual voltage at the time depending on position in mains cycle) being offered up to the 'target'. This may not make any difference but has the 'greater potential :-) to do so
In my printer example, if the printer cable had been connected to the PC before the printer was turned on it would have grounded the floating printer via the printer ground connections and thence to PC ground. As that was how the printers were regularly supplied I'd be nearly certain all would have been OK. Instead the printer ground at 1/2 mains via caps killed the printer interface (or internals). In that case it was probably not gnd-gnd but some signal-signal path at 1/2 mains. But with a randomish target as per question the same may apply. Some few laptops have extra logic in the psu lead (eg some Dells, aiming to stop you using 3rd party substitutes.) Also laptops and similar are not usually hard grounded but may be or they may be "soft grounded via a conductive surface.Worst case damage can happen and occasionally does.