How can someone patent something they didn't invent? Magnetic shielding is a science fiction mainstay. Even I have included this device in short stories written decades before this patent, and I believe that a working version of hull polarisation already exists. Is this patent legal? Most science fiction TV series includes various forms of polarisation protection.
First, you can't patent something you didn't invent. Period. In order to get a patent you have to sign a document under penalty of perjury saying you were the inventor. If you weren't the inventor, you can be prosecuted. However, after the America Invents Act changed our system from "First to Invent" to "First to File", it is now possible for an inventor to get a patent on something that somebody else invented first. Inventor 1 invents on January 1 and files for a patent on March 1. Inventor 2 invents on February 1 and files for a patent the same day. In this case, Inventor 2 gets the patent.
Since you can't patent an abstract idea, an abstract idea is also normally not going to be prior art for the purposes of preventing somebody from getting a patent. For example, the abstract idea of the Star Trek "Holodeck" is not going to prevent somebody from getting a patent on technology that actually implements a Holodeck-like environment. If you were to find science fiction that tracks the claims (hard sci-fi writers might be a good place to look), then you could potentially find valid prior art to knock out a patent. Using the patent you cited as an example, the issued claim covers:
A spacecraft magnetic shield apparatus comprising: an armature having a first end and a second end, the first end adapted for being connected to a spacecraft; an electromagnet connected to the second end of the armature; a computer determining the position of the armature and electromagnet in relation to the spacecraft; and a power source powering the electromagnet; wherein the positioning of the electromagnet is generally in line with incoming charged particles or ion radiation and powering of the electromagnet creates a magnetic field that deflects a percentage of the incoming charged particles or ion radiation from directly impacting the spacecraft.
So just hearing Captain Archer tell the Enterprise crew to "polarize the hull plating" is not enough to anticipate two-ended armature with an electromagnet and a computer for determining position of the magnet, etc. However, if there was an episode where they said "we need to fix the polarizer for the hull plating, the arm with the electromagnet on the end isn't coupled to the computer or power source any more, so it isn't deflecting the radiation" -- well, that might present a patentability problem for the '406 patent you reference.
An idea can't be patented, and somebody else having had an idea doesn't prevent somebody else from patenting it. A patent explains the exact method of how to do something. The government grants patents to people because they are a benefit to society-- somebody figures out a novel way of doing something, so the government grants them a time-limited monopoly in exchange for the inventor telling everybody how they did it, so that anybody can do it after the patent expires.
Back to the Future featured the "Mr. Fusion" device, which made tons of energy out of food waste that was stuck into it. It doesn't exist, and the fact that it was created for a sci-fi movie won't preclude any inventors from making and patenting a device that happens to do the same thing. And here's the key point: you can patent a Mr Fusion because the sci-fi authors didn't publish exactly how it works.