Hello,
Today I will show you connections between Task attachments in Microsoft Project for the Web, and Microsoft Groups.
First I will create brand new Project with one Single Task:

IF I want to attach a Document to Task, I will get:¸

As you can see, I can only add a link to the URL, not an Attachment! WHY?
To answer this question, let me assign a group to this particular Project:

As you can see I am using existing group, but I could create a brand new one.
Now all three options for Task attachment are available:

Now I will attach one simple picture From computer, and I will get:

If I want to attach a file From team files I will get:

and:

As you can see in Teams files I can see only file which I already attached.
Let me, for a moment jump to a Microsoft Group. To do that, I will jump to Outlook in my Office 365:

and I will get:

As you can see, file which was attached to the Project is here. Now I will jump to a SharePoint site created for this particular group:

As you can see file attached to the Task is in SharePoint site created for the Group. So, the answer for the question above is: “Until I don’t have a group assigned to the Project, I cannot attach a file, because Project doesn’t now where to place it!”.
I will now upload two new files to the SharePoint site:

Let’s go back to the Project. If I now try to add attachment from Team files I will get:

To conclude, each file which is attached to the Task is stored to SharePoint site which belongs to the Group which is in turn, assign to a Project.
If I attach a file from my computer directly to the Task, it will be saved in that SharePoint, and if I save a file in that SharePoint, I can attach that file from Team files. SO, Team files = SharePoint files.
Regards!