You are correct, there are many ways of calculating what is correct and what isn't correct.
It depends on your resistor, and the data sheet of the resistor will tell in which way the power handling capability is defined.
For example you can apply DC and the power limit is as specified.
You can also apply a pulse of 4x the rated power voltage for quarter of the time, so the average is the same, but your power still momentarily was 4x the rated power handling.
Depending on how slow or fast the pulse was, the resistor might handle it without damage or they will damage.
Some resistors are especially designed and rated for handling high pulsed power peaks as long as they are within limits.
So what you saw on the website is just calculating the RMS average power dissipation. It may or may not be suitable way to calculate it in all cases, depending on the resistor. To be fair, the frequency is 1000 Hz which makes the peak to be very short, in comparison to mains frequency of 50 or 60 Hz, so you might get away in this case by just calculating the RMS power, but same resistor might damage when used at 10 Hz.
How you need to calculate it depends on the resistor. It will be safer if you simply use the peak power as the limit.
But, these calculations also do not consider that the power handling capability of a resistor depends on it's temperature too, so even if the rated power handling is listed at 25 °C, it does not apply when resistor has heated itself to 100 °C.
The example seems to assume the temperature does not need to be considered, even though in real life it does.