Non-existent child page URLs redirects to the image attachment URL instead of throwing 404

If I understood you correctly you want to disable all attachment pages and redirect them to 404 page. Place this code in functions.php and try it again.

 add_action( 'template_redirect', 'redirect_media_to_404' );
 function redirect_media_to_404() {
    if ( is_attachment() ) {
       global $wp_query;
       $wp_query->set_404();
       status_header( 404 );
       get_template_part( 404 ); 
       exit();
    }
 }