Yoast had a bug a while back that turned a setting off in your Yoast setup which may have affected some rankings. WOMP WOMP.
They mention in a post about attachment URLs, “We quickly resolved the bug, but some people have suffered anyhow (because they updated before our patch). This post serves both as a warning and an apology. We want to ask all of you to check whether your settings for the redirect of the attachment URLs are correct. And, for those of you who suffered from a decrease in rankings because of incorrect settings, we offer a solution that Google has OKed as well.”
Luckily, this is a super easy adjustment to make—as Yoast outlines the process to update the media/attachment URL settings in a recent blog.