Writing to /var/www and other questions

Yes correct, a file or folder can be owned by one user and one group. Usually access to a shared folder is managed by the group as multiple user can be member of this group. On DietPi we use the DietPi user group to share file access between multiple applications. A typical use case on DietPi are thinks like Radarr, Sonarr, a torrent client and some music/video player.

Back to your folder test

drwxr-xr-x  2 www-data www-data  4096 May 13 18:20 test

As you can see it has write permission for user www-data only. Nobody else can write on this folder. Even www-data group members not. For this you would need to set write permission for the group as well.