A dog will generally shake their leg when you stroke or tickle them on the back or flank. This region is known as the 'saddle region' and can be an extremely sensitive part of your dog, although the exact area will vary from dog to dog. The shaking of the leg is an involuntary reaction, like when the doctor tests your instinctive reactions by hitting your knee with a neurological reflex hammer, and your leg jolts out of its own volition.
As this shaking of the leg by your dog is a mere spasm that they are powerless to control, there is no way to stop your dog from doing it, other than by not touching their saddle region in the first place. If the dog is shaking their leg to an extreme degree or without you having touched them at all then it would be advisable to take them to a vet to be looked at, as it is possible they may be suffering from muscle atrophy (wasting of the muscles) which could in turn be a symptom of something else such as diabetes or kidney failure.
It could be a result of Arthritis or Hip Dysplasia, a common genetic disease occurring in mainly larger dogs, usually from birth, which causes hip joints to grow abnormally and can be very painful for your dog. It will be highly likely that it won't be anything to worry about but it is always best to be sure when it comes to your dog's health.
As this shaking of the leg by your dog is a mere spasm that they are powerless to control, there is no way to stop your dog from doing it, other than by not touching their saddle region in the first place. If the dog is shaking their leg to an extreme degree or without you having touched them at all then it would be advisable to take them to a vet to be looked at, as it is possible they may be suffering from muscle atrophy (wasting of the muscles) which could in turn be a symptom of something else such as diabetes or kidney failure.
It could be a result of Arthritis or Hip Dysplasia, a common genetic disease occurring in mainly larger dogs, usually from birth, which causes hip joints to grow abnormally and can be very painful for your dog. It will be highly likely that it won't be anything to worry about but it is always best to be sure when it comes to your dog's health.