Akismet blocks spam by using machine learning algorithms to analyze comments and trackbacks submitted to a website. It compares the content of each submission against a database of known spam, and if it detects spam, it flags it as such or automatically moves it to the spam folder.