Instantaneous and active power in an ideal switch powered by real source and squared wave
It seems clear that the instantaneous power is null, since the voltage
  is 0 when the current flows and the current is also 0 when the switch
  is open. It seems quite intuitive.


No, when 100 amps taken by the resistor (switch closed), one side is shorted to 0 volts and the other is at 100 volts hence, the power dissipated during that closure is 10 kW.

What you seem to be considering is the power dissipated by the switch and, of course, for an ideal switch, that will be zero.


  In this case, it can be seen that the power is no longer equal to 0,
  as there is at least one DC term


Just because there is at least one term that is DC positive does not mean that there are not other terms; such as sin(nwt)*-sin(nwt), that produce DC negative terms that cancel the positive term. Do the math.