Very sudden changes in behavior can be a sign that there's a medical problem, no matter how young or old the dog is. For example, she could have impaired vision, making it hard to recognize you and read your body language. She could also be in pain, making her shy away from touch to avoid more pain. Where this pain comes from is another question... There could also be problems in the brain. Only a vet could diagnose any of this.
This could also indicate a change in behavior in another person (or you). Dogs will react that way if someone in the household starts mistreating them. But it doesn't have to be abuse. When my grandma started getting dementia, the dog picked up on it before we did and suddenly didn't want to be in her room anymore. We are 100% certain that she never hurt the dog or abused her in any way, though. Maybe your behavior changed in ways you're not even aware of, but the dog noticed.
As mentioned in the comments, a change of smell can also cause this. Strong perfumes / deodorants are an obvious reason, but many drugs and medications can also change your personal smell. It could also be a smell you bring home from a friend or boy-/girlfriend.
Your posture may also influence the way she acts around you. Many people only bend their body down at the hips when interacting with a dog. But from the dogs perspective they are towering over them in a very scary and intimidating way. Whenever your dog acts scared of you, you should sit down on the floor instead of standing or crouching. That makes your posture much more friendly and you more approachable.
You should encourage her to come to you, but then give her time to explore you without touching her. If a smell or a noise (maybe from your clothing) triggered her, she then has the opportunity to learn that whatever it is, it's not a bad thing. But she needs time to concentrate on that, and she can't concentrate when you touch her. You can speak to her in a very calm way, though.
You should monitor when these sudden lapses in trust occur and then recall anything that happened before it started. Have you moved in a certain way? Eaten certain foods or taken certain medications or drugs? Have you or the dog been with certain people? Has it been cold and wet outside? (This can influence painful conditions like arthritis.) Try to find what caused this, then try to change it.
After this answer was written, you wrote in a comment that she is a rescue dog and is often in pain. This makes it even more likely that
- She's either in pain in those situations where she shies away. That's a very common behavior in dogs that feel pain when moving (for example in the joints). They're afraid of being touched in a way that hurts, so they preventively keep their distance.
- Or she was abused in the past and something you did reminded her of how someone hurt her.
I also have a rescue dog who is very erratic in his behavior. At first we didn't understand why he would act so illogically, until my mom was putting dried laundry away. She was holding a wooden cloth hanger and took just a few steps towards me to tell me something, when suddenly our dog yelped and ran away. It dawned on us that he was abused and hit with wooden sticks.
My mom sat down on the floor and very calmly called the dog to her, holding the cloth hanger to the side. It took him some courage, but eventually he approached my mom and took his time sniffing at the cloth hanger. She moved it very slowly towards him to give him time to react. Eventually she could touch and pet him with the cloth hanger and he lost his fear.
But we're certain that this wasn't his only negative experience. He still has erratic reactions to situations where we aren't aware what triggered him and we'll probably never know everything he went through.