Writing a murder mystery means getting in the minds of both murderers and detectives.
With the murderer, it is understanding what motivates them. A good way to do this is to build up a profile for each character containing as much information about them as possible such as what they look like, where and when they were born, what they like to read, how they like to be entertained and what they like to wear. The writer should amass as much information as possible and can keep it as a separate file but it should be used sparingly in the novel. The reader should be able to work out most of it for themselves.
In the case of the detective, the author should investigate the murder as if it was a real crime. A good way to do this is to draw a map showing the position of the body and each suspect at the time the killing took place. If it is a police procedural thriller then the story should be as scientifically accurate as possible. Here internet search engines can be helpful to gain access to forensic science websites. Different police forces follow different procedures which change over time. It is not necessary that they are exactly right but they must be believable. The same is true for historical fiction where modern methods such as DNA analysis have yet to be invented.
Once these basics are followed then the various twists and turns can be wound in and around the investigative procedures to provide a narrative that entertains both reader and writer.