wp_get_canonical_url showing first url of the post for custom page

This is because wp_get_canonical_url can only be used on posts, and cannot be used for tags authors archives etc.

Returns the canonical URL for a post.

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

More specifically, no equivalent exists for tag archives because archives and listings do not have canonical URLs. A canonical URL indicates to a search engine the correct and canonical location of a piece of content, but an archive is not an item of content, it’s a collection/list.

Instead, it would be more logical to use the archive URL of the queried term, say get_term_link:

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

Just keep in mind that this too is semantically incorrect, the alternate link rel is for specifying alternative countries and locales, not the canonical URL:

If you’re using a multilingual plugin then you will need to look up how they handle this or your tag will always refer to the current locale.