Clean Taxonomy terms in new post type wordpress

Your code is not listing the terms from post A, it is listing all the terms on your site. You can test this by creating a post Z and adding new terms to Z, you will see those new terms listed on all posts, even post A.

The reason is this:

$terms = get_terms($taxonomy);

get_terms does not get the terms on the current post, it just gets terms.

If you only want the terms the assigned to the current post, you need to use wp_get_post_terms instead

$terms = wp_get_post_terms( get_the_ID(), $taxonomy );

https://developer.wordpress.org/reference/functions/wp_get_post_terms/