They say it's hard to teach an old dog new tricks. This probably holds true when you try to teach a dog things that don't come naturally to it. Some examples are commands like fetch, roll over, beg, etc. But with patience and lots of love, even old dogs quickly pick up the essential training.
A dog, whether young or old, is very sensitive to the feelings of its master. It sees and senses which of its actions bring you happiness and which don't. And it also knows that its own happiness depends on yours.
In the natural wild state, a dog never defecates or urinates where the pack is resting. It always goes some distance away for that, and then returns to the lair. So it is easilly home trained, even in later life. Similarly, it's easy for a dog to learn commands like sit and down, because these are actions that it does naturally too, on its own ..... and it soon learns to associate your command with that action ... and it obliges to make you, and thereby itself, happy.