The log above is from 1.17.1, which is different than your initial screenshot. That issue is because you need to uninstall OptiFine

I'm not sure about the 1.18 issue, because there's no information