The electrostatic potential energy of a point charge $q$ at potential $V$ is $$U_E=q V \tag{1}$$
The electrostatic potential energy of a capacitor that has been charged with charge $q$ at potential $V$ is $$U_E=\frac{1}{2}q V \tag{2}$$
The magnetic energy of a single loop of (constant) current $i$ in a (uniform) magnetic field $B$ is $$U_M=-m \cdot B=\mathrm{i \Phi(B)} \tag{3}$$ Where $\bf{m}$ is its magnetic moment.
The magnetic energy of a single loop of (constant) current $i$ in a (uniform) magnetic field $B$, when the process of setting up the current in the loop is consider, becomes: $$U_M=\frac{1}{2}i \Phi(B) \tag{4}$$
My question is: why when these factors $\frac{1}{2}$ appear exactly?
I mean, if one does the calculation they comes out with no doubt, but take the case of the loop in magnetic field: it seems quite paradoxical that the same loop, firstly consider as a "magnetic dipole" and then as a loop (with self inductance $L$) reaches two different energies in the same field $B$.
The same for the electrical case: if I consider a "very little" conductor, I should get the same thing as of the single point charge but that's not the case.
Besides why I get the factors $\frac{1}{2}$ I would like to know how can I relate the two cases, that is, for example in the magnetic case, how do I get to $(3)$ from $(4)$? If I start with a loop and $(4)$ holds, can I get to $(3)$ under some assumptions?