Well, forum website does have algorithms that detect a users usage and the behaviour. They also have moderators specified that always are very active in identifying these spammers.
But one the basic techniques they use to identify you as a spammer by receiving feedback from other users about you, that is if they mark you as a spammer or not. You might have seen various forums having a specific button to flag someone or to identify someone as a spammer. Well more you will be flagged, more you’ll have the chance to be identified as a potential spammer.
Users with high flags are reported to the moderators and then they can review the activity and user’s behaviour and then decide whether the user is a spammer or not.