Spam is a english meat product you get in a tin.
Monty python does a sketch about it where a bunch of vikings start singing over the top of the conversation in the foreground "Spam spam spam spam spam spam spam spam lovely spam etc..."
Essentially they drown out everything else. This term was adopted by computer users to refer to unwanted junk email as it made the legit emails in your inbox hard to locate amongst the "spam" ones, in much the same way you couldn't hear the conversation due to the singing.
This led to the word being used to pump out something at a high speed (i.e. junk emails). This in term was then used for throwing lots of something out - e.g. spamming LRM or spamming trade ports or spamming HCs etc...
Hope that sort of makes sense....