Egypt and Turkey show the perils of ideological religious parties, but other Muslim countries are faring better with democracy