Why this is so weird
It sounds like a cartoon superpower, but it is a real last-resort defence. The spray can startle predators, and National Park Service material reports that the blood is especially unpleasant to canine predators such as coyotes.
What is actually happening?
Horned lizards have several defensive layers before blood-squirting: camouflage, flattening or inflating the body, and presenting their horns. The eye-blood defence is not a trick every lizard uses; it is documented in horned lizards of the genus Phrynosoma, with variation among species.
The detail that makes it even better
The useful nuance is that this behaviour is not their everyday response to danger. Horned lizards normally rely on camouflage and body shape first, which makes the blood jet more accurately described as an emergency defence than as a routine weapon.
Sources
U.S. National Park Service — Greater Short-horned Lizard
U.S. National Park Service — Grand Canyon Short-Horned Lizard