Your issue isn’t related to your WordPress theme. Image attachments are created by WordPress, not by your WordPress theme. You can use SEO plugins (e.g. Yoast SEO) to prevent image attachments from being indexed by Google.