Earth-like planets may form even in harsh environments, James Webb Space Telescope finds