There could be other, unknown, factors that happen to affect BOTH: a person's IQ and their likelihood to be infected, along with severity of infection. For example some genetic, environmental, or other variable that affects your IQ as well as infection-resistance.
It very well might be true, that infection does have the ability to lower IQ. But this study does not prove it.
I wish scientists would be more straightforward about conclusions. The title of the article should read: "Study finds that individuals who have suffered infection have a lower IQ than the general population" or something along those lines. Much different than saying that "infection lowers IQ".
This is beginner-level confusion of causation and correlation.