"Watchbird" by Robert Sheckley. Project Gutenberg etext. Here is a scanned copy of the original Galaxy publication with illustrations by Ed Emshwiller. That story has appeared in these collections; if the one you read it in was from about 50 years ago, it was probably one of these. More information here; this story has been identified before, but with different plot points in the question.
Examples: preventing surgery because the incision would harm the patient,
The nurse handed the surgeon the sponge.
She placed it in his hand. He started to make the first incision. And then he was aware of a disturbance.
"Who let that thing in?"
"I don't know," the nurse said, her voice muffled by the mask.
"Get it out of here."
The nurse waved her arms at the bright winged thing, but it fluttered over her head.
The surgeon proceeded with the incision—as long as he was able.
The watchbird drove him away and stood guard.
"Telephone the watchbird company!" the surgeon ordered. "Get them to turn the thing off."
The watchbird was preventing violence to a living organism.
The surgeon stood by helplessly while his patient died.
not allowing a farmer to turn off his tractor.
Jackson yawned and pulled his car to a shoulder of the road. He didn't notice the glittering dot in the sky. There was no reason for him to. Jackson wasn't contemplating murder, by any human definition.
This was a good spot for a nap, he decided. He had been driving for seven straight hours and his eyes were starting to fog. He reached out to turn off the ignition key—
And was knocked back against the side of the car.
"What in hell's wrong with you?" he asked indignantly. "All I want to do is—" He reached for the key again, and again he was smacked back.
Jackson knew better than to try a third time. He had been listening to the radio and he knew what the watchbirds did to stubborn violators.
"You mechanical jerk," he said to the waiting metal bird. "A car's not alive. I'm not trying to kill it."
But the watchbird only knew that a certain operation resulted in stopping an organism. The car was certainly a functioning organism. Wasn't it of metal, as were the watchbirds? Didn't it run?
Vaguely remember the robots giving electric shocks; in one instance, a person died from a weak heart, all because he was trying to swat a fly.
The fly buzzed around the room, lighting on a table top, pausing a moment, then darting to a window sill.
The old man stalked it, a rolled newspaper in his hand.
The watchbirds swept down and saved the fly in the nick of time.
The old man writhed on the floor a minute and then was silent. He had been given only a mild shock, but it had been enough for his fluttery, cranky heart.