Unset image sizes before images are uploaded

You get $sizes as array, where size name is a value, not a key

Try this

    //remove sizes with init hook and remove_image_size
    add_action('init', function ($sizes) {
        remove_image_size('2048x2048');
        remove_image_size('1536x1536');
        return $sizes;
    });

    // or just return sizes you need
    add_filter('intermediate_image_sizes', function ($sizes) {
        return ['thumbnail','medium','large'];
    });