Especially popular, frequently-spidered wikis are beloved targets of spammers because of ease of access. If they can get their URLs on a popular wiki page for a few hours, their "ratings" go up because search engines find them.
Often spam is made invisible so that only the search engines can easily see it; but "edit mode" usually reveals it.
Dealing with spam
Most of our responsible contributors look at the list of recent changes. The ability to "hide logged in users" helps. Spam is removed when seen.
Administrators can block users and have a "Rollback" power that makes reversal very quick and efficient. Other contributors can reverse by simple deletion of added material or (if the spammer replaced good material) by going through the page history back to the last good version and resaving it.
Sometimes our vigilance is not perfect and a page has been hit twice in succession, so it pays to check that the version you are restoring is an uninfected one.
Vandals or careless visitors
See Help:Vandalism. If someone seems to have been experimenting with no malicious intent, maybe Template:Test on the contributor's talk page is the best approach, in case a friendly response results in a new serious contributor.