The SEC’s handling of cases involving Justin Sun and Elon Musk was among the factors that caused the agency’s top enforcement official to quit, according to sources.