These two words do not have the same meaning, although they sound similar.
Meaning of "scam" in English:
noun - a dishonest plan for making money or getting an advantage, especially one that involves tricking people
verb - to trick someone into giving you money or giving you some advantage, in a dishonest and often illegal way
https://dictionary.cambridge.org/dictionary/english/scam
Meaning of "spam" in English:
noun - unwanted email, usually advertisements
verb - to send someone an advertisement by email that they do not want
https://dictionary.cambridge.org/dictionary/english/spam