Suppose we have a voltage source with an EMF of $\mathcal{E}$ and an internal resistance $R$. If we connect to it a perfect wire with zero resistance, we get a short circuit. The value of the current is determined by: $$I=\frac{\mathcal{E}}{R+0}=\frac{\mathcal{E}}{R}$$
Then the voltage across the source would be $V=\mathcal{E}-IR=\mathcal{E}-\mathcal{E}=0$ volts. Now I want to find how much power is dissipated do tue the current inside the source (e.g. Joule heating inside a battery due to collisions of electrons with ions). The formula is pretty simple:
$$P=VI$$
So for this example $P=0 \cdot \frac{\mathcal{E}}{R}=0$
But we can rewrite the formula using Ohm's law:
$$P=VI=I^2 R$$
And then it would be $P=\frac{\mathcal{E}^2}{R} \neq 0$
We get here a contradiction. Where is my mistake here? Maybe I have a wrong understanding of voltage? Is it because we have an EMF i.e. some non-electrostatic force which does work despite the fact we have short-circuited the source? The voltage itself as I understand describes an electric field which is not present. So maybe we should use instead of $V$ in Joule's heating formula an emf? But then, it still confuses me a little, because the formula itself is derived from Ohm's law and the electrostatic fields.