n Lightning Experience, drag files directly onto the Files related list or click Upload Files. To add Salesforce Files, click Add Files in the related list’s menu.
In Salesforce Classic, click Upload File in the Files related list.
If you want attach file via code then please try to make instance of ContentDocumentLink object and add the LinkedEntityId to the specified parentId for it.