In Yoast 7.0, Yoast stated: “there was a bug concerning attachment URL’s.”
They proceeded to fix the bug but depending on how fast you updated your website’s plugins. you may have been affected.
Make sure the redirect ATCH URLs are set to Yes.
To fix this problem, you will need to check the plugin on the site.
1. Go to search appearance on the Yoast Plugin. (If this doesn’t show up then you may not have the latest Version of Yoast.)
2. Click on the Media Tab.
3. The “Redirect attachment URLs to the attachment itself?” setting should be set to “Yes” unless you are using this function for a specific reason.
And that is all you have to do to fix the bug!