Roald Dahl must have had many reasons for deciding to make the character of Patrick Maloney a policeman. Perhaps the most important was that the response to his murder would be greater and last longer. The house is filled with cops looking for clues, including a murder weapon. They stay a long time, which is essential because Mary needs a long time to cook a frozen leg of lamb. And there are plenty of hungry cops to devour it when it is ready. The cops are giving special attention to the crime because it happened to "one of their own." They want to be sure the murderer is caught and punished, and they naturally assume this was a revenge killing by some hardened criminal whom Patrick had arrested at some time in the past.
Another reason that Patrick's profession is important to the story is that his wife Mary has learned a lot about police procedure from being married to a cop. She establishes an alibi before she calls to report the murder. She quickly proceeds to destroy the murder weapon by putting it in the oven and turning up the temperature as high as it will go. She knows most of these cops personally. They all believe she is a devoted wife and that she and Patrick had a happy marriage. It is common for the police to suspect a spouse in a domestic murder, but Mary is almost above suspicion because she really was a loving wife until she succumbed to a sudden rage and bashed her husband over the head with the frozen leg of lamb.
The fact that Patrick was a policeman meant that his own behavior was exemplary. When he tells Mary he wants a divorce, he says certain things that show the investigators will find nothing in his personal life that will suggest Mary might have been motivated to kill him out of jealousy.
"So there it is," he added. "And I know it's a tough time to be telling you this, but there simply wasn't any other way. Of course, I'll give you money and see that you're taken care of. But there really shouldn't be any problem. I hope not, in any case. It wouldn't be very good for my job."
This suggests that Patrick has been leading an exemplary life because he wants to get regular promotions. We see, anyway, that he could hardly be carrying on an extramarital affair because he keeps such regular hours.
When the clock said ten minutes to five, she began to listen, and a few moments later, punctually as always, she heard the car tires on the stones outside, the car door closing, footsteps passing the window, the key turning in the lock.
We do not know everything Patrick told Mary during the time covered in the following paragraph:
"This is going to be a big shock to you, I'm afraid," he said. "But I've thought about it a good deal and I've decided that the only thing to do is to tell you immediately." And he told her. It didn't take long, four or five minutes at most, and she sat still through it all, watching him with puzzled horror.
But there is no reason to believe he told her he was in love with another woman. Patrick must want out of the marriage because he feels suffocated by all the attention he gets from his clinging, needy, mothering wife. The cops will naturally look into Patrick's off-hours activities, but they won't find anything irregular.
Another reason that Roald Dahl must have decided to make Patrick a cop was that Mary would know many of the investigating officers personally. This would allow for a little laxity in their professional behavior. When she invites them to eat the fully cooked leg of lamb, they do so because they feel she is "one of their own." They would not behave the same way if they were investigating a murder in the home of strangers.