submit two file input fields in the same form

Here’s what I think is happening. I’ve added comments to the relevant sections of your code.

// You use the $_FILES superglobal to get the uploaded files.
if (isset($_FILES['file_metabox'])) {
    $file_metabox = $_FILES['file_metabox'];
    foreach ($file_metabox['name'] as $key => $value) {
        if ($file_metabox['name'][$key]) {
            // ...
            // Here you **overwrite** the $_FILES superglobal.
            $_FILES = array("file_metabox" => $file);
            //...           
        }
    }
   
}

// So here, $_FILES['file_cert'] **no longer exists**.
if (isset($_FILES['file_cert'])) {
// ...
}

I would recommend using a different variable name, so that you’re not overwriting the content of $_FILES.

For example: replace

$_FILES = array("file_metabox" => $file);

with

$my_files = array("file_metabox" => $file);