unattached media files that should be attached

It’s not a problem with WordPress. It’s how it should be. If you see the image below of media library.

Media Library WP

You can see that the column name is Uploaded to which means that media file was not there before and it’s introduced or uploaded to the below mentioned post/page/etc.

Since in your case it’s uploaded to the old post and not new post the media file is in detached state, as while you were creating the new post the media file was already there, so the Uploaded to doesn’t really fit here.

Although I sometimes feel that Attached/Detacthed is a bit confusing.

Basically here Attach/Detach refers to the registration of the media file to the particular post while uploading to the Media Library and not whether it is used in the post or not.