I had something similar happen to me:
I started with a Sylvanas Windrunner on board, then on my opponents turn they played a Convincing Infiltrator. Back to my turn, I cast Ancestral Spirit on my Sylvanas and proceed to clear the whole board. I anticipate that because I played Ancestral Spirit after he played his Convincing infiltrator, his deathrattle will go off first before my Sylvanas is revived. Unfortunately for me that's not how it panned out, and my Sylvanas was revived first and was subsequently killed by my opponent's infiltrator deathrattle.
I was confused by this, so I did a little research and found https://hearthstone.gamepedia.com/Ancestral_Spirit
The Deathrattle granted by this spell activates immediately after any Deathrattles the minion already had before Ancestral Spirit was cast.
As far as I know, a magnetic minion behaves similarly to a spell when played in magnetic-mode. Did this mech which was magnetized onto already have a deathrattle, if so it may be the same interaction at work which I encountered with Ancestral Spirit.