Attach media to multiple posts

It is not possible to assign multiple parents to the attachment. However, there is an alternative solution. You can use update_post_meta. to store the attachment id to the post and similarly, you can use function get_post_meta. for getting the attachment id.