The rules for making skill checks are usually cut and dried. If a character is making a check to see if they can swim against a current, this would usually be a Strength (Athletics) check.
But the rules allow for unique circumstances to require skill checks with atypical abilities.
For example, if you have to swim from an offshore island to the mainland, your DM might call for a Constitution check to see if you have the stamina to make it that far. In this case, your DM might allow you to apply your proficiency in Athletics and ask for a Constitution (Athletics) check.
Certain races afford the character advantage on specific checks. For example: the Loxodon's Keen Smell (Guildmasters' Guide to Ravnica pg 18):
Keen Smell. Thanks to your sensitive trunk, you have advantage on Wisdom (Perception), Wisdom (Survival), and Intelligence (Investigation) checks that involve smell.
Stonecunning. Whenever you make an Intelligence (History) check related to the origin of stonework, you are considered proficient in the History skill and add double your proficiency bonus to the check, instead of your normal proficiency bonus.
Or Rock Gnomes' Artificer's Lore:
Artificer’s Lore. Whenever you make an Intelligence (History) check related to magic items, alchemical objects, or technological devices, you can add twice your proficiency bonus, instead of any proficiency bonus you normally apply.
Using the Loxodon as an example, I can imagine a situation where a DM might request an Intelligence (Perception) check to see if a character is able to identify which of two glasses of wine is poisoned or a Constitution (Perception) check to see if a character can keep their eyes on something flying very close to the sun without squinting.
In these atypical scenarios, does the creature's racial benefit still apply to the check in spite of the fact that the fundamental ability being used with their skill is not the one explicitly cited in the description of their racial feature?