The Katakana are on the top panels. This is from the manga Beezlebub.
The author says ザワザワザワ。。。here as onomatopoeia for commotion in the audience.
Kanji does not make any sense here because Kanji has meaning and its meaning is not reflected in
its pronunciation. Katakana has no inherent meaning, so it works.
Katakana is probably used instead of hiragana because hiragana is used so much for grammatical things in the language, and katakana here can be used to distinguish.
Also, commotion in the audience is usually a bunch of people talking together, so there's a bunch of sounds going on at the same time. Katakana looks sharp, and sharpness can reflect the many individual voices. By contrast, the top right panel's "Oooooo" by the audience is in hiragana because "oooo" is a very soft, round sound, and hiragana matches that.
This is from a video game ad I found on Google.
The speech bubble says エキサイチング, which is English for "exciting."
I think this is the main function of katakana in Japanese -- for loan words.
I suppose katakana was used for sounds before foreigners came to Japan, so naturally,
the Japanese language would use katakana to model these foreign "sounds" phonetically.
Also, katakana is so much simpler than kanji and so much sharper than hiragana that it is impossible
to mix up the three. Since hiragana is used so often for Japanese grammar items, it makes sense
to use katakana for foreign words.
The textbooks explain katakana differently because, I suppose, there are no set rules for when to use
katakana or not. It just seems natural to use katakana for distinct sounds, foreign words, and emphasis, all of which are kind of "sharp" and different. Essentially requires a different type of attention from the reader as opposed to kanji and hiragana. Therefore the author just goes by "feeling" which one to choose.