Police in South Africa are hunting suspects after 27 people were killed in two separate mass shootings.