The "magic" is in the first line. The %EVAL macro will evaluate it's argument when the code is run.
So when n=4, the first line evaluates to
%EVAL( 4 + %mysum(3) ).
This causes the %MYSUM macro to be run with a new argument. This time the first line evaluates to (dropping the %EVAL call, for convenience)
3 + %mysum(2).
This continues recursively until the argument n=1, in which case the macro generates
1
Cumulatively, the macro generates an expression that is equivalent to
%EVAL(4 + %EVAL(3 + %EVAL(2 + 1)))
which is displayed in the log by using the %PUT call.