As an example, i have 2 classes, both doing almost the same stuff:

public class PlayerManager : MonoBehaviour
{
    void Update()
    {
        RaycastHit hit;
        if (Input.GetMouseButtonDown(0))
        {
            Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
            if (Physics.Raycast(ray, out hit))
                Move(hit.point);
        }
    }

    public void Move(Vector3 position)
    {
        // Move to given position
    }
}

public class NpcManager : MonoBehaviour
{
    void Update()
    {
        RaycastHit hit;
        if (Input.GetMouseButtonDown(0))
        {
            Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
            if (Physics.Raycast(ray, out hit))
                Move(hit.point);
        }
    }

    public void Move(Vector3 position)
    {
        // Move to given position
    }
}

Instead of detecting mouse click and finding hit.point in both classes Update, i’d like to move that code to a third class, which would then call the Move method of PlayerManager and NpcManager.

Of course i could require both scripts via GetComponent or other ways, but as my classes grow this becomes quickly unmantainable.

Any suggestions on how can i do this in a way that is mantainable even when expanding the codebase?

For classes that are supposed to do mostly the same thing you should use inheritance. You make virtual methods so the inheriting classes can override if they need to do the same thing with a different code. It will keep your code manageable and fast.