get_categories() function retrieves the list of category objects and you’re looping through categories, not the custom posts. So, The code posted here will echo category link, not the individual custom post link.
When you haven’t created any custom taxonomy template, It will by default bind it to archive.php
you can have more idea about template hierarchy at: https://developer.wordpress.org/themes/basics/template-hierarchy/
If you echo custom posts link then it would bind it to single-gallery.php
. To create a custom taxonomy template you need to bind it to taxonomy-{taxonomy}.php
Hope this will help you!