For older dogs experiencing toilet training difficulties you first have to find out if it was a rescue dog was it kept in kennels for a while as this often causes dogs to unlearn toileting discipline.
In this case, you need to go back to crate training and relearning the basics.This can be found at the bottom of this page under (1) Puppy Toilet Training.
The older dog that suddenly starts urinating and defecating in the home where previously they were clean, then this problem can occur for a wide range of possible reasons.
Medical, mental decline, spay Incontinence, bladder/urinary and a number of other possible scenarios… Sometimes you may need an assessment from your vet. If that shows no issues it could possibly be behavioural. If so a behavioural assessment could be considered,
Take into consideration the age of the dog, and the possibility that there could be medical reasons for this behaviour especially if it has suddenly started.
This distressing problem can be caused by a trauma or change in circumstances such as:
(1) A Recent House Move
(2) Other Dogs Have been To Your House.
(3) Frightening Experiences such as Loud Bangs or Fireworks etc.
(4) A Death in The Family or a Crisis.
(5) Tension or Stress in the Family Unit.
(6) The Death of Another Dog in the Household
If it is a sudden change in your dog’s normal behaviour, it could be caused not by behaviour but by medical problems.
Bladder or bowel infections or other medical problems could be the reason. Check with your vet first. It’s also rather common for older especially spayed bitches to start dribbling.
It is actually called Spay Incontinence. This happens to about 20% of all spayed females. What a pity your vet forgot to tell you that when they were badgering you to neuter your dog. This is more common in females that were paediatrically spayed.
Doses of oestrogen. can help with the common problem, the doses can be tapered off after a few months. Some dogs require oestrogen for the rest of their lives.
Defecation is not usually a problem as much as urination can be. However, the most often recommended remedy for a dog that defecates in the house is to change its feeding times, so that you are likely to be walking the dog when it needs to defecate or it is outside in the garden. This will take some time as you will need to experiment with the amount, frequency, and timing of feeding your dog to get the results you want.