Looking at your code and the code for the WP function I only see one thing that could be causing this.
https://developer.wordpress.org/reference/functions/wp_get_attachment_image/
Question: is the class populated with anything?
Possibly there is a filter on ‘wp_get_attachment_image_attributes’