Problem Insert Data to connected tables postgresql
So I figured it out eventually
        WITH insert_projekte AS
            (
            INSERT INTO projects (name, projekt_status_id, creator_id, editor_id, inserted_at, updated_at)
            SELECT name, projekt_status_id, creator_id, editor_id, inserted_at, updated_at  
            FROM temp_units
            RETURNING ID, name
            )
                        
INSERT INTO units (kgnr, ez, projekt_id, creator_id, editor_id, inserted_at, updated_at)
    SELECT t.kg_ez, t.ez, insert_projekte.id, t.creator_id, t.editor_id, t.inserted_at, t.updated_at
    FROM temp_units t
    JOIN insert_projekte on
    insert_projekte.name = t.name
    RETURNING ID

I always left the subquery in the second INSERT so it never worked before.
Thank you @CL. for the helpful suggestions.