Were frills used as defenses in ceratopsians? Right now, some scientists think not. In most ceratopsians, the frills were just skin stretched over bone, so a predator could just bite right through it. I think that interpretation is wrong.
First, let's find an analogy. What protective item exists that is a skin stretched over a frame? We find such objects in Africa. They are leather shields. African hunters used them to protect themselves. Lions tend to attack the nearest part of an opponent, such as a shield, leaving the soft-parts of the human unscathed. The shield makes it hard for the lion to get a clear attack at the human's vitals even though it is otherwise flimy. The jaws of a lion are designed to bite around something and not bite a flat object. When the lion does succeed in a bit, it bites the frame far more often than it bites the person. If the lion rakes, it rakes the leather and not the person. Humans use these shield because they are highly effective.
You may ask yourself, "Why doesn't the lion avoid the shield?" Be careful there. Humans attribute too much intelligence to other creatures. This is normal. The term is anthpomorphication. People anthropomorphize creatures all the time. We attribute to them human perceptions and intelligence. That is a mistake. They do not cognate as we do.
The wolf is a clear example of this. A wolf attacks by biting legs and tripping creatures. Let's walk with a cane and see what happens. A wolf does not see you and a cane. A wolf sees you-and-cane as one creature. Not being able to tell the difference, it uses its default tactic "grab nearest leg" even though one of those legs is a dead stick.
In a second example, wolves are captured by hanging rags off string. You then close the loop and the wolf is trapped. Even though the wolf can escape easily by walking through the rags, it can't do that because it perceives the rags as a solid wall. The wolf is a very smart carnivore, yet it is fooled by the appearance of solidity, rather than solidity itself.
Given those examples, lets look at the ceratopsians again.
Most ceratopsians have a frill. A carnivore attacking a ceratopsian will not distinguish the frill from any other part of the ceratopsian. In fact, given the frill's size, it will certainly try to bite the frill. The frill is just skin and bone, so it presents a false target to the carnivore. It will bite the frill but and in doing so fail to deliver a critical strike.
If this observation is true, then we should find ceratopsian with bite marks on their frills, and these bite marks should show signs of healing. In fact, we find many of these things. This directly shows that the frills were a defense.
Any medieval reenactor will tell you that a shield is more useful than a dumb object that just sits there. A shield is part of a dynamic defense. You are not just standing there taking blows, you use the shield to make blows hard to target and hard to land. You also use a shield to knock around the other guy's weapon or the other guy. The frill makes it very hard for the blunt-nosed carnivore to land a good bite on the neck. The frill pushes away the bite even as the bite is closing. If he does get behind the neck, he uses his massive neck muscles to shove the shield backward into the predator's face, likewise deflecting the predator's attack. (Some ceratopsians had frill spikes to help out.)
How would a ceratopsian encounter a predeator? If you are a beak-faced little dinosaur with no other protection, you must face your predators. Your only advantage is your massively strong beak. You need to keep that ready. This creates a pressure to be good at facing your enemies. A ceratopsian could flee, but it has already sacrificed lightness for the advantages of its beak, losing your food-gathering advantage is not an option.
An carnivore is now stuck with attack a beak-faced herbivor. It needs to attack behind or under the neck, or get a good chomp out of the flank. The creature turns to keep its nasty beak ready to chomp your leg. A two-legged predator with a bad leg quickly becomes an ex-predator, so you need to be careful and go around that beak. The targets are the jugular and behind the head. If you can get there, you can win the fight.
With this pressure, ceratopsians have a reason to grow a frill: it makes getting behind the neck harder. Ceratopsians also have a reason to grow a longer nose: it makes it harder to get to the jugular.
A big carnivore can step on your nose, though, and that gets you right there. So a ceratopsian also needs a way to discourage a carnivore up-close, so there's lots of pressure to develop horns and other heavy-metal equipment. This stops the run-you-over approach. One type has a weird horn which is a perfect trap. It looks much like the hook from some types of polearms used for disarming or tripping. Tripping a two-legged predator is a pretty good tactic.