We know it's a WPML-related problem, because I've read from several places that WPML is the cause and because what causes the problem is the change in the .htaccess file to the WPML RewriteRules. When this happens all pages, except the home page, give an error.
Upon investigation we saw that the problem is that WPML overwrites the correct .htaccess (listed first below) with one that has the wrong paths (listed second below).
It was not possible to understand if there is interference with other plugins, because it is a problem that occurs every now and then, without continuity and without apparent causes.
Thank you for contacting WPML Support, I will gladly help you.
It might not be related to your issue, but from the debug info you provided, I noticed that you are using WordPress v6.2.4, I would suggest you update to the latest version
---
The issue you are facing is not caused by WPML, it comes from certain third-party plugins calling flush_rewrite_rules(true) function too often. This causes WordPress to overwrite .htaccess.