It wasn't magnets. Magnets were just an analogy.
I'm not sure why people are still confused. They also clearly explained it in the episode. The answer was made up barely pseudo science so I can see people thinking the answer was dumb. But I don't know why people are just confused. I heard the answer, I got the gist of it, I realized I didn't care because it didn't make any sense, and I moved on.
Essentially, it locked the signal from the bomb (or something like that, could have been the molecular structure of the bomb itself) to the portal, which caused the portal to suck them in.