They are generally word-matched, which can result in problems, hence these amusing juxtapositions. However, apparently recently Google has created a sort of black-list of words (ie. suicide, slaughter) that, if they're present in an email, will result in no ads being shown...so they're aware of the problem: http://homepage.mac.com/joester5/art/gmail.html
this could lead to people appending their e-mails with a list of such words (suicide etc) much as some did (was it late 90s? post-911?) with lists of terror-related and ordinary-subversive-related words, back in the day
I think the appending emails stunt was around 99, certainly before 9/11 at least. From memory it started as a way to "thwart" the surveillance tactics of the man by including so much noise into emails it would be impossible for (and I forget the name of the computer that was meant to do this) the machine to keep up..
I'm not sure how the ads get chosen in the example systems above - maybe they're random - but I've seen some amazingly bad Google ads matchups while reading the Age. I guessed they must be selected through keyword match, like other Google ads, and that in a newspaper context this can backfire, leading to examples like the above. Does anyone know if the 'picture' ads above are inadvertently chosen via word-match or whether they're random?