There are various mechanisms and techniques:
-Captcha
-answer of simple questions (what noise do a dog?, what is 1+7, what's the day after sunday...)
-and more
But it’s not great, to enter it every time/every post

And there are real persons, who are paid to spam boards.
In this case, protection becomes difficult...
to keep board clean but still comfortable :
Manual removal of ulcer by moderator, admin...