Why my nginx conf file redirects subdomains to main domain?

Please show nginx configuration of your subdomains.

EDIT 1:

Try adding this config file (name it as you wish):

server {
    listen 80;
    server_name my-subdomain-name.my-domain-name.com www.my-subdomain-name.my-domain-name.com;
    return 301 https://$server_name$request_uri;
}

server {
    listen 443 ssl;
    
    server_name my-subdomain-name.my-domain-name.com www.my-subdomain-name.my-domain-name.com;

    ssl_certificate /etc/letsencrypt/live/my-subdomain-name.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/my-subdomain-name.com/privkey.pem;

    include /etc/letsencrypt/options-ssl-nginx.conf;

    location / {
#      You can change port, url if you wish
        proxy_pass http://localhost:4000;
    }
}

EDIT 2:

For example you have this subdomain: test.my-domain.com Then you have to set up your server to serve files from that subdomain. For that, we've to create a nginx config file.