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 NPS sources report 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 (genus Phrynosoma), with variation among species.
Sources
U.S. National Park Service — Greater Short-horned Lizard
U.S. National Park Service — Grand Canyon Short-Horned Lizard