You need to load your existing file, before creating a new one each time and override the previous.
.....
$doc = new DomDocument('1.0');
if($xml = file_get_contents( 'customer2.xml')){
$doc->loadXML( $xml, LIBXML_NOBLANKS );
$root=$doc->getElementsByTagName('customers')->item(0);
}else{
$root = $doc->createElement('customers');
$root = $doc->appendChild($root);
}
$customer = $doc->createElement('customer');
$customer = $root->appendChild($customer);
.....
$doc->save('customer2.xml');