set_post_thumbnail() shows Unattached on backend under Media

If you’re uploading files via your own form, a file is attached by setting post_parent of the attachment to the ID of the post you want it attached to. Setting a post thumbnail doesn’t attach the file to that post.