I tried several times to cook the glaze for a strawberry glaze pie and the sugar, water, and cornstarch would thicken but then the sugar would turn grainy. I have also tried to boil water, sugar, and butter to make a carmel type sauce to pour over corn curls and it thickens and seems to be fine but then turns grainy right after I take it off the stove.
It sounds like your syrups are crystallizing on you.
For a smooth glaze or caramel, you want tiny little sugar crystals. When you heat your sugar and water mixture, after a certain temperature the water becomes super-saturated with the sugar.
After this super-saturation point, things get dicey. If the solution is disturbed--say by stirring, or an undissolved sugar crystal or other foreign particle getting into the solution--the sugar can rapidly come out of solution and form big crystals. This could be why your confections are grainy.