Caramel sauce becomes grainy if the sugar recrystallizes. This can happen when some liquid sugar syrup splashes up onto the sizes of the saucepan and immediately turn into crystals as they cool down. If this crystal touches the melted sugar in syrup, it causes a chain reaction and the sauce will seize up and become grainy.