I am trying to understand how NMR works, but I am not sure why a spinning nucleon produces a magnetic field. Is this a consequence of the quark structure inside?
It's certainly true that a classical charged object that spins generates a magnetic field; the moving charges form current loops. If you're trying to understand NMR this is probably a good-enough model for the nucleon magnetic moments.
Quantum-mechanical spin is a different creature, though, and thinking about it classically can get you only so far.
As @rob has already pointed out, the classical model (Uhlenbeck and Goudsmit model) of spin magnetic moment as a result of the particle spinning around its axis is not correct. The reasoning behind this model is that a rotating charged ball can be seen as a circular current, generating magnetic field according to the Bio-Savart law. This mechanistic view is not consistent with the actual size and charge density distribution of electrons and protons, and certainly doesn't work for neutron that has no electric charge.