Its because the node you put probe is getting affected by capacitive and Inductive loading.There are various other factors, (power noise/ harmonics) but proper Calibration can reduce this.Using a small resistance in the series ( dampening the output voltage) can also reduce the spiks loaded on square wave.
A poor ground, or an excessive loop area between ground
clip and probe, can add a lot of inductance. Inductance is
what makes for voltage overshoot (capacitance makes
current overshoot, but you're not looking at current).