Grainy toffee can result from sugar crystals forming in the mixture. The crystallization can be from overcooking the toffee or water coming into contact with the mixture.