The caramel must be cooked to the appropriate temperature -- make sure to use a thermometer. Another reason could be that it's not been baked long enough -- bake longer for it to harden.