The NPC AI, at its base layer, operates on Maslow's Hierarchy of Needs. That is to say, before an NPC will consider higher-minded behaviors like "What do I need to do to be the best blacksmith in this town?" they first think about their physiological needs, then their safety needs, then their social needs, and then their internal needs, before they think about how to be the best [whatever their career is] in the settlement.
If any of those lower tier needs go unmet for long, the NPC will ask and answer questions like "Do I need to move on from here and find a new home town?" and act on those answers to resolve their issues. The thresholds at which NPCs begin to consider drastic steps like that depends on their Big 5 personality values. That said, they will all eventually take drastic measures to ensure their basic needs, desire for safety, and hope for sense of belonging are met.
Hope that helps! :)
Edit: So, to address the original question HajimeSaiko, if the NPC in question thinks they can address their need, for example, for food, by jumping in and assisting the farmers, they will. However, generally speaking, an NPC won't seek to change their profession, and they won't attempt to improve land or infrastructure that isn't theirs to address. If the farmer doesn't open the land up for folks ot help, they won't. Likewise, if the town hasn't opened up things for people to come help, say, build a well, no one will come help because they've essentially been told they can't, and that option to address their physical need for water won't be on the table for them.