Caramel recipes become grainy when the sugar grains in the caramel crystalize. If this happens to your recipe, you can fix it by mixing in a small amount of an acidic ingredient like lemon juice to break down the sugar crystals.