what I don't understand if my working is valid is how you can convert
an ac signal into a dc signal in a question and apply it just like
that to the resistor which is in an ac circuit. Basically, how can you
apply a dc voltage in an ac circuit to find the average power in a
resistor?
The right thing to do is always calculate with the U(t) and I(t) and get a momentary power P(t). But this is complicated and we EEs are lazy and want a quick shortcut. If you are out in the field you do not want to sit down and solve an integral but quickly get a number.
$$ U(t)=\hat{U} cos(\omega t) $$
$$ I(t)=\hat{I} cos(\omega t) = \frac{\hat{U}}{R} cos(\omega t) $$
$$ P(t)=U(t)\cdot I(t) = \frac{\hat{U}^2}{R} cos^2(t) = \hat{P} cos^2(t) $$
Average over one period $$ \omega T = 2\pi $$
$$ \frac{1}{2\pi} \int\limits_0^{2\pi} cos^2(\alpha) \, d\alpha = \frac{1}{2\pi} \int\limits_0^{2\pi} \frac{1+cos( 2 \alpha)}{2} \, d\alpha = \frac{1}{2} $$
(where the hat above the symbols stands for "peak")
So the average power over one period is 1/2 the peak power.
$$ \bar{P} = \frac{\hat{P}}{2} $$
(where the bar over P stands for "average")
The same power would be caused by a DC voltage and DC current of:
$$ U_{RMS} = \frac{\hat{U}}{\sqrt{2}} $$
$$ I_{RMS} = \frac{\hat{I}}{\sqrt{2}} $$
Then conveniently
$$ U_{RMS} \cdot I_{RMS} = \frac{\hat{U} \cdot \hat{I} }{ \sqrt{2} \sqrt{2} } = \bar{P} $$
So this way you can conveniently continue to calculate with the RMS to get power ratings without doing the integration.
The RMS then also works for different curves then sine if you calculate the "root means square"
$$ U_{RMS} = \sqrt{\frac{1}{T} \int\limits_0^T (U(t))^2 dt } $$
This depends on the wave form. Typically you know the ratio of peak to RMS for certain wave forms and then use it to calculate the power.