The other answers are pointing in the right direction, but the real problem usually sits somewhere else: Check the subwoofer's power cable itself - if it's run right next to or bundled together with the RCA cables, that creates a classic ground loop. The RCAs need to be spatially completely separated from the power cable, ideally on the other side of the car. Plus, it's worth checking the amplifier's ground connection to the chassis ground point - a lot of people underestimate how important a large, clean metal surface there is. If the hum is still there after that, it could also be a cheap or too-long ground wire causing the problem - a short, thick cable run directly to the battery negative terminal often works wonders.