I want to follow up on this topic because I discovered that it is not a good idea to add:
ProxyErrorOverride On
.. inside the Apache configuration because it can cause problems on some websites.
The problem is that 'File not found' is only shown for .php files, if it is .html, .jpg, etc. it shows a page created for error 404 but if it is .php then the message 'File not found' is shown. So my question was why it doesn't show a custom 404 error for files that don't exist and end with the extension .php
This is the best way to solve this problem for now:
Inside the web config / vhost file (aapanel -> Website -> choose a website -> Config) put this part:
# Custom 404/403 for static files
<FilesMatch "\.(html|htm|css|js|png|jpe?g|gif|svg|ico)$">
ErrorDocument 404 /errors/404.html
ErrorDocument 403 /errors/403.html
</FilesMatch>
and finally put this part in the .htaccess file:
# If the PHP file does not exist → show custom 404
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/admin
RewriteRule \.php$ /errors/404.html [L]
You have to change the path yourself, in my case the error 404 file is located in the root, error folder, error404.html file.