Why does get_post_status display published when attachment is in trash?

The post status for attachments is inherit. You get the status for the parent post, not the real status. And that is probably still published.

error code: 523