Zeokat Because you don't run composer as root, and normal users don't have the permission to edit www-data owned folders.
Every time you need to install flarum or use composer you should chown it recursively, do what you must and when you're done restore the www-data chown recursively from the flarum root folder. You should never run composer as root.
All of these guides are quite outdated, maybe I'll create an updated script for both apache and nginx tomorrow as well as php7.4 since I'll need it soon anyways.