nginx location serve different root

 server {

        listen 80;
        server_name example.com;
        return 301 https://$host$request_uri;
}

server {
         listen 443 ssl;
         listen [::]:443 ssl;
         include snippets/self-signed.conf;
         include snippets/ssl-params.conf;
         root /var/www/html/folder1/public;
         index index.php;
         server_name example.com;

         location / {
                try_files $uri $uri/ /index.php$is_args$args;
        }

        location ^~/pma {

               # rootfolder is /var/www/html/folder2/public and  
               # it makes query into: /var/www/html/folder2/public/pma


                root /var/www/html/folder2/public;
                index index.php index.html index.htm;
                try_files $uri $uri/ /index.php;

                location ~*\.php$ {
                        include snippets/fastcgi-php.conf;
                        fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
                        fastcgi_read_timeout 300;
                 }


        }


        location ~ \.php$ {
                include snippets/fastcgi-php.conf;
                fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
                fastcgi_read_timeout 300;
        }


}