You are having an issue because this is a list form and attachments are handled differently there - you'll notice the attachments field isn't repeating. If you attach some files in preview and go to File > Save As and look at the XML, you'll see that there is nothing stored in the attachments node.
The only work around I can come up with is:
- Add a query (receive) connection to the same list that the form is for
- Set the query to NOT run on load
- Include the ID and Attachments in the query.
- As part of your logic that needs to check for the count of attachments, set the ID field in the query fields for the new data connection to the ID from the main data source in your form.
- Execute the query
- Count the returned repeating attachmentUrl field in the secondary data connection
Of course - this all only works if your form has an ID in the main DS, which means it has to have been submitted at least once.