According to canon lawyer, Dr. Ed Peters, “In brief, the granting of an annulment petition does nothing to affect the legitimacy of children” (100 Answers to Your ANnulment Questions).
Although a marriage may eventually be declared null by the Church, a legal or civil marriage did take place. Thus it would be inaccurate to say that the children were illegitimate in such cases.