If you want to add a unique field to content type so that Drupal would prevent you from entering the same field value more than once you can add a validation constraint to your field. There is two ways to do that:
How to properly structure custom code in Drupal 8/9/10 ?
When your custom module or theme start to get bigger and you add a lot of hooks in your .module or .theme files it becomes unreadable and hard to maintain with thousands of code lines.