Moz calculate the spamscore based on different factors like onsite and offsite factors.
Offsite factors: backlinks' quality, backlinks' spam links, backlinks' penalty, backlinks' backlink
Onsite factors: spammy content, 4xx/5xx errors for pages you have built backlinks.
Backlink quality what matters for each search engine, if a spam website is linking to your website then your website might get spam.
Backlinks' spam links: Sometimes you don't check each website you build backlink on. Their backlinks sometimes get spammy, so you get the risk also.
Backlinks' content: Backlinks' quality is measured by its content. Most of the link builders just put content on the website and paste their links. They don't post quality content, so that content doesn't get internally linked or externally. So, such links on high authority websites are called spammy backlinks. It won't affect that website but yours.
OnSite Factors: The major factor which is neglected is that you removed a page from your website either to remove duplicate content or merge them or delete it, you have to put the 301 redirections of to a similar page. Normally 4xx/5xx pages are noindex by default in every CMS. To transfer its link juice/authority you need to put 301 redirection.
I got a project "Boston criminal Defense Lawyer" the previous link builder built too many web 2.0's with spun content, there were nearly 1000 web 2.0s. Web 2.0s are normally good if high-quality content is written and updated regularly. But he used just spun content with exact match keyword. That cost the project drop ranking and lost google's trust on the domain. Hence those web 2.0 has no spam score so our website didn't have spam score.
If you have a paid subscription of Moz, then you should do at least do your website's audit every month. This can help you keep your website spam free. Also, keep your backlinks in check with Moz link checking tool.