This will happen when it isn't stored in an airtight container. The moisture will evaporate when exposed to air, and the sugar hardens into a dense mass of sugar rather than softer granules.