trigger on 2 tables one to many
In a trigger fired AFTER the insertion it makes no sense to modify the NEW record, as it has been already inserted. Use a BEFORE trigger.

CREATE TRIGGER trg_calcul_altiinf 
BEFORE INSERT OR UPDATE ON table2    -- + UPDATE
FOR EACH ROW EXECUTE PROCEDURE calcul_altiInf();


In the function body you should query only the table1, as the current value of n_sd is in the NEW record:

IF TG_OP IN ('INSERT', 'UPDATE') THEN    -- + UPDATE
    NEW.alti_inf = (
        SELECT z - NEW.prof 
        FROM table1 
        WHERE NEW.n_sd = table1.objectid);
    RETURN NEW;
END IF;