Many people believe that Styracosaurus and other ceratopsians used their horns and frills to defend themselves from potential predators. However, it is now believed thtat this was not their primary purpose, if it was one at all. Instead, they were probably used for display.
A more likely explanation is that they travelled in herds to protect themselves. Related species have been found in massive bonebeds like this, and it is entirely possible that the sheer mass of flesh and horns would be enough to discourage a predator.