The ads you see aren't necessarily the same ones that others here see (and, of course, the vast majority of AB members don't see any ads at all because we've all got that-which-shall-not-be-named-here installed on our computers anyway), so it's hard to know exactly which ad you're referring to.
However the advertising systems which AB gets its revenue from are, indeed, configured to seek out key words in current posts and deliver the most appropriate (or possibly inappropriate) ads. Those same systems are also linked to other websites so if, for example, you search elsewhere on the web for garden gnomes, you're likely to see ads for them appearing here when you view AB.