The justices ruled in one case that a law allowing suits for aiding terrorism did not apply to the ordinary activities of social media companies.