Why do neutron stars have such powerful magnetic fields?

This is indeed a perplexing and not fully-solved problem. It used to be stated that flux conservation alone might lead to fields of order $10^9$T which are deduced to be present at the surfaces of many rapidly rotating (and presumably young) pulsars. A 10 solar mass star on the main seqeunce has a radius of about 10 times that of the Sun, say $10^{10}$m. If it collapses to a radius of $10^{4}$m then flux conservation might lead to a field amplification factor of $\sim 10^{12}$. This would then require mean fields of around $10^{-3}$T (or 10G if you prefer) on these main sequence stars.

This kind of B-field strength in high mass main sequence stars is plausible and so a collapsed "fossil field" with flux conservation might explain a fair fraction of pulsars, but there is now a new class of pulsars known as magnetars that have fields up to 100 times stronger than most pulsars. The required progenitor mean fields of 0.1T are rarely seen in normal main sequence high-mass stars (e.g. Petit et al. 2006). In addition the "fossil field" model has the problem that the neutron star only contains about 15% of the mass of the progenitor, so is unlikely to possess all of the flux. In addition, if such strong interior fields were present during the star's pre-supernova evolution then it seems unlikely that the collapsing core would be able to spin-up to the rapid rates observed, because magnetic coupling to the envelope would transfer away angular momentum (e.g. see Spruit 2007).

For these reasons, the many recent avenues of theoretical exploration have centred around some sort of magnetic field generation mechanism (a magnetic dynamo or through magneto-rotational instabilities driven by differential rotation) that happens during the collapse of the core and possibly acting within the very hot proto-neutron star itself (see for example Thompson & Duncan 1993; Mastrano & Melatos 2011).

Having said that, the "fossil field" idea is not dead. Magnetars do rotate more slowly than most "normal" pulsars of similar age and it may be that they are born of stars that do have unusually strong magnetic fields (e.g. Ping et al. 2019; see also this popular article). Another idea is that a "fossil field" could be boosted by paramagnetism. Peng et al. (2006) suggest that superfluid neutrons in the $^3P_2$ state might boost the initial field by factors of $\sim 1000$ as the neutron star interior cooled sufficiently to allow superfluid neutron pairs to form. In a similar vein, Peng et al. (2007) suggest paramagnetism of the degenerate electron gas in the neutron star interior, resulting in field amplifications of $\sim 100$. Neither of these latter two works seems to consider that field may be excluded from the neutron star interior by the Meissner effect due to superfluid protons.