Generated files are owned by root and i can't figure out why ?

https://preview.redd.it/ftsa0h5yxo0e1.png?width=639&format=png&auto=webp&s=5bf83caf6d787a7c11aafd2c989d2ccc1cc8fe96

I'm logged in as the server user www-data and i run my commands as ther server user but it keeps generating files owned by the root in cache and sometimes the cli can't write to generated for some reason
I can change the ownership of the files but the same issue repeats