It doesn't have any way of being that smart, as there's no way to tell a job which item is the one that defines the job from the viewpoint of the player.
Making it that smart was what my next paragraph was about.
It would be nice if Toady One could set it so that for workshops that require more than one type of item, if a stockpile is linked to it for one of those types, then it will only use that stockpile for that type, but for the other (unlinked) types it will still take them from anywhere. This would solve a lot of the "oops, forgot to link a fuel stockpile to my smelter too" type problems.
That might be an easy enough rewrite, if the game checked for general availability after failing to find any job items in a linked stockpile. You'd need a third level of linkage (strict limiting to linked stockpiles, as it is now) to stop dwarves from wandering off elsewhere for materials if their feeder stockpiles got emptied. I don't know how you'd code a job item counter without having to add something to every job in the game...
You simply do it this way. For example, the still needs some kind of brewable plant material and some kind of container in order to work. So, when a stockpile is set to give to the still, the still checks those two slots to see if the stockpile(s) connected to it fill both those slots, if not, then that slot is set to "take from anywhere". So if you had a stockpile that accepted some kind of brewable plant, but no empty containers, then set it to give to the still, the still would set "plants: take from stockpile X ; containers: take from anywhere". It's entirely based on the stockpile
settings, and not the stockpile's
contents. If the source plant stockpile is empty, then the still wouldn't be able to brew anything until some brewable plants got stored in that stockpile.