As Thai authorities investigate Thursday’s ghastly mass killing of 36 people by a former police officer, they are also confronting the role of their own ranks in the country’s distorted gun market and gun culture.

The gunman, Panya Kamrab, 34, used a 9 mm pistol he obtained legally, police said. He also owned a shotgun. And before he was fired from the police force in June on drug possession charges, both would have been easy for him to buy. Thailand’s security forces can purchase as many weapons as they want through the government, and at a steep discount.

Civilians seeking to buy guns, by contrast, face tough laws and high prices — a disparity that creates perverse incentives and other problems. In some cases, it has led those charged with public safety to sell caches of weapons for profit.