This (the warning) is only possible if WhatsApp can read your messages
I'm guessing that they read your message on the app. So their claim (end-to-end encryption) is indeed true and correct.
But their app can and indeed has been reading your messages, for the past, at least, 3 years
Which I personally don't mind, when it's done fully automatically (no humans involved) and only for this kind of uses (to warn users of dangers)