Like almost all content in WordPress, a Media item (aka attachment) is stored in the
wp_posts table, and its metadata is stored in the
wp_postmeta table. The
wp_postmeta data is linked to the post by the post ID. If the Media item is set as an attachment to a specific post, then inside the
wp_posts table its
parent is set to the Post ID of the actual Post. Items uploaded directly to the Media Library are unattached - that is, they have no parent set. In either case, the attachment/Media item itself only has one type of meta - whatever metadata is assigned to it, which can be seen either in the Media Library or in the Insert Media modal.
If you edit media meta (such as the alt text) in either the Media modal while editing a post, or within the Media Library directly, WP saves that to the database in
wp_postmeta associated to the media itself and will use that meta whenever you add the media to a new Post/Page/CPT. However, if you edit the alt text or other information within the Editor - just in the post content itself - that only gets saved to the
wp_posts table of the post itself - it only affects the HTML within the associated Post. It does not change that attachment's saved metadata, so if you then add the image to a different post, it will use the
wp_postmeta alt text from the image and not the updated alt text you used inside a post.