South African police on Sunday were hunting the perpetrators of two separate shootings that killed 27 people within hours of each other, in stark reminders of the country’s problem with gun violence.