More often than not the posts or threads are made by a 'bot' which is basically a script or program although there are still a few who make them by hand. They open an account and start trying to post advertising links or URL to websites. The forum board won't allow links to be posted by new members so they try to make enough posts to become sufficiently established to be able to post links. The spammers are paid for posting the links because it raises the profile of the website in google search results by affiliate linking which means they can charge more for their advertising.
Often the forum board defences will detect the attempted posting of links and file the post in the 'moderation queue' where it sits until a mod or admin checks it and manually makes it visible or deletes it. For every spam post that makes it onto the board there's two or three that you don't see, it's a full time task dealing with them sometimes. Some innocent posts also get caught by the filter which often causes the member to duplicate post again so before an innocent post is made visible we need to check for any duplicates as well.
Once in a while a spam thread gets several genuine replies. If there's valid advice been given or if the reply posts have any value, instead of just dumping the spam opening post (which would result in the entire thread disappearing) I prefer to close the thread so the replies don't disappear then leave a comment after banning the spammer manually.
All part of the joys of moderating.