It went grainy
Updated
On this page7
It was stirred while too hot
Agitating a hot supersaturated syrup lets a small number of crystals form and grow large. The instruction to cool undisturbed before beating exists precisely to prevent this, and ignoring it is the most common cause by a wide margin.
Something seeded it
An undissolved sugar grain, a crystal on the side of the pan, a dirty spoon or a scrape of the pan bottom late in the cook. Washing down the pan sides during the cook and not scraping the pan when pouring are both about removing seed material.
The formula had nothing holding crystals back
Corn syrup, invert sugar, acid, butter or milk solids all interfere with clean sucrose crystallization and keep crystals small. A recipe adapted to remove one of those, often for label reasons, will grain unless something else takes its place.
It can also develop over time
A product that was smooth when made can grain on the shelf as crystals slowly grow, particularly if it dries out or is stored warm. That points at the package and the storage rather than at the cook, so the date it appeared matters.
You cannot fix it in the finished product
Reheating and reworking a grained batch can sometimes recover it by dissolving the crystals completely and starting again, which means treating it as raw material rather than as a product to rescue. Selling it as a rustic texture is not a serious answer.
The log tells you which of the three
Cook temperature, when it was agitated and at what temperature, and the formulation version. Without those the three causes are indistinguishable and you are guessing at a fix.