So what lets a neutron star turn into a Magnetar
The actually reason is unknown ,but researchers say that it can be because of a perfect temperature, magnetic field ,spin rate it sets off a dynamo mechanism that amplifies the magnetic field by a factor of thousand.
On recent discovery of a Magnetar in our milky way galaxy gives them some clue about how they form,that is :-
This Magnetar is a rogue one that is located on the escape trajectory of the milky way , this means they are ejected when one star detonates in a binary system of stars.While they were partner ,the two stars orbited one another closer than the earth and the sun,this leads transfer of material back and forth.In this the larger one dies first ,puffing out and transferring material to the smaller one,.This makes the smaller star grew larger and spewed material back to the first star.Initially smaller one detonates as a supernova first ,ejecting the other star into the escape trajectory and then the second went off,but instead of forming a regular neutron star all these binary interactions turned it into a Magnetar.
Lets give a magnetic comparison scale :- earth's core has 25 Gauss , a regular neutron star has a trillion Gauss and the Magnetar has a quadrillion Gauss.
So what happen if we get closer to a Magnetar:
Well within about 1000 kilometers the magnetic field is so strong it messes with the electrons in our atoms , You would literally been torn into atomic level