Both westerns and mysteries are properly crime fiction: sheriff's procedurals and police procedurals; the procedures vary, but there is usually some personal code of behavior, good and bad, and handguns.
Quite a few authors who are best known for their mysteries started with, or also wrote, westerns. James Lee Burke wrote Two for Texas in 1982.
We know Elmore Leonard primarily as mystery writer, but the first story he sold was "The Trail of the Apache." His best-known western is probably Hombre.

