The Attachments count component makes it possible to show to show the number of attachments for the current document.
Add the Attachments count component inside a Conditional visibility component set to Attachment list is not empty to only show it for documents with attachments.