In “The Adventures of the Speckled Band” the theme of the story is that evil will be punished by fate if not by man's instruments of justice.
The story demonstrates a kind of karma. The doctor commits evil deeds, and those deeds pave the way for him to destroy himself. He trains the snake to be his instrument of death, and the snake returns to him to kill him.
Holmes comments that a doctor who harms people is dangerous not just because he violates the Hippocratic Oath to do no harm.
When a doctor does go wrong he is the first of criminals. He has nerve and he has knowledge. (enotes pdf text p. 17)
The mystery centers on how Sir Grimesby Roylott, a dotor, manages to commit murder without anyone suspecting. Holmes determines that he has used his reputation for eccentricity, and his animal collection, to accomplish this. He trains a snake to do the murders for him. Yet it is also the training of the snake that causes his demise, because Holmes attacks the sake and sends it back to him.
Some of the blows of my cane came home and roused its snakish temper, so that it flew upon the first person it saw. (p. 20)
Roylott would not have been killed if he had not trained the snake to do his dirty work. He was punished by fate, karma, or his own evil. In the end, he got what he deserved, and Holmes did not really have to play a part in it.