I couldn't find any good sources for an answer.

Some random person on Reddit said: "MRI scans can sometimes cause neuro stimulation and it can feel like slight shocks because of a nerve being stimulated."
https://www.reddit.com/r/MRI/comments/gdhby5/nsfw_did_the_machine_that_does_mris_just_shock_me/

Somebody on Quora said: "Most likely you experienced peripheral nerve stimulation from the magnetic fields. It’s fairly common and completely harmless."
https://www.quora.com/Why-did-I-feel-a-shock-in-my-hands-during-a-brain-MRI