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.