Apologies if it seems like I'm picking it all apart but understanding the dog's behaviour may help you;
"usually when dd goes to stroke her. This time dd was just reaching for a toy beside where the dog was lying." I'd say, management wise, from now on DD should not be interacting with the dog except for the purpose of training. Interactions should be led by the dog. As DD is quite young, it may not be possible to be able to explain this sufficiently to her so may just be a case of strong management.
"She's also very nervy and timid but I have no idea why, my gran has had her from being a pup and nobody has ever hurt her although she was attacked by a larger dog once (no major injuries)." t may be that although your gran has had the dog since a puppy she never properly socialised her. Experiencing lots of different things as a puppy is important. Just as important is giving these things associations. Exposure to children is no good unless a positive association is made. Perhaps your gran's dog experienced its exposure to children as either neutral to negative. This doesn't seem farfetched considering young children move strangely, make weird noses, run around a lot and can be quite grabby. All scary things that need to be counteracted by introducing something positive such as play or lots of food. Even then interaction needs to be relatively well controlled as to not overwhelm the dog (especially what would have been a teeny puppy). If your gran never bothered with any training it seems likely she didn't do the above quite thoroughly enough :(
"I'm struggling to know what to do. My gran won't go anywhere without the dog so I can't ban her from the house but at the same time dd comes first." Will she be willing to work with a behaviourist (as she sounds devoted) and for the dog to be behind a stair gate or similiar during your visits? The dog may even feel safer this way- not having to be too close to DD.
"I think it's linked to her feeling nervous and sometimes she will growl to warn us off which is fine but other times she strikes with no warning." If she regularly growls at people I think it's quite possible that when she's not growling she is in fact not comfortable, but whatever signs she is showing of this are much less noticable than a growl. If she is giving few signals preceding her bites then even more important to get a behaviourist in. Google 'ladder of aggression' to give you some idea of the other signals she may be giving in the build up to a bite.
Really my main "idea" as it were would be for your gran to contact a behaviourist, or leave the dog at home. Or both. The dog sounds like maybe it leads a rather stressy life. For its own welfare a behaviorist might be good regardless. The dog needs to build a new positive association between the children and any interaction they have with her (however limited that is). They may also be able to take more details about the particular 'incidents' where the dog has bitten and consider if there are other common factors to suggest more than general anxiety around the children (guarding of some sort, handling issues). Also encourage your gran to get the dog checked over by a vet. I don't know how old it is or how long it's been exhibiting these behaviours but pain and disease can alter a dog's behaviour dramatically.