united-states
But what is that legal reason? Why would an organization not be able
to state their position with respect to the issue, such as "We believe
we acted correctly, but this will be decided in court"?
Is there a law saying that commenting a court case is illegal? Who
does this apply to? Or is this just some guideline or established
advice to avoid problems (which ones)?
Legal Ethics Considerations
There are circumstances when commenting publicly on litigation violates the ethical rules for lawyers related to trial publicity See Rule of Professional Conduct 3.6 (the numbering system for professional conduct rules for lawyers is uniform nationally in the U.S. although the substance of the rules can differ in detail from state to state - Colorado's rule is fairly typical). Mostly this rule calls for avoiding statements that could prejudice a jury unless the other side has already done so and those statements need to be rebutted. This rule states (in its Colorado version):
(a) A lawyer who is participating or has participated in the
investigation or litigation of a matter shall not make an
extrajudicial statement that the lawyer knows or reasonably should
know will be disseminated by means of public communication and will
have a substantial likelihood of materially prejudicing an
adjudicative proceeding in the matter.
(b) Notwithstanding paragraph (a) and Rule 3.8(f), a lawyer may state:
(1) the claim, offense or defense involved and, except when prohibited
by law, the identity of the persons involved;
(2) information contained in a public record;
(3) that an investigation of a matter is in progress;
(4) the scheduling or result of any step in litigation;
(5) a request for assistance in obtaining evidence and information
necessary thereto;
(6) a warning of danger concerning the behavior of a person involved,
when there is reason to believe that there exists the likelihood of
substantial harm to an individual or to the public interest; and
(7) in a criminal case, in addition to subparagraphs (1) through (6):
(i) the identity, residence, occupation and family status of the
accused; (ii) if the accused has not been apprehended, information
necessary to aid in apprehension of that person;(iii) the fact, time
and place of arrest; and (iv) the identity of investigating and
arresting officers or agencies and the length of the investigation.
(c) Notwithstanding paragraph (a) and Rule 3.8(f), a lawyer may make a
statement that a reasonable lawyer would believe is required to
protect a client from the substantial undue prejudicial effect of
recent publicity not initiated by the lawyer or the lawyer's client. A
statement made pursuant to this paragraph shall be limited to such
information as is necessary to mitigate the recent adverse publicity.
(d) No lawyer associated in a firm or government agency with a lawyer
subject to paragraph (a) shall make a statement prohibited by
paragraph (a).
Statements such as "We believe we acted correctly, but this will be decided in court" are allowed and are not terribly uncommon. But, making a comment about something that can be easily inferred from the publicly available documents filed in court provides little or no positive advantage for a litigant.
Also, one doesn't have to say much to create at least a colorable Rule of Professional Conduct 3.6 issue that a mediator can raise in settlement talks, or that a judge can be forced to analyze. Even if the claim of unethical trial publicity ultimately doesn't hold water, it still muddies the waters and distracts lawyers and litigants from dealing with the substance of the dispute.
The Risk That A Statement Will Be Used Against You
Usually, the main concern is similar to the concern about talking to police: Anything you say can and will be used against you at trial.
For example, this week former President Trump's public statement about his knowledge of classified documents, which are the subject of an ongoing federal criminal investigation of him, seriously harmed his position legally. (His statement was made quite a while ago in a semi-private forum, but at a time when the possibility of a criminal investigation still should have been on his radar screen.)
In the civil rape-defamation case against him (as noted, for example, in this Law.SE answer), Trump's decision to continue to speak publicly about matters that were the subject of active litigation against him in an earlier case resulted in an extended statute of limitations and an opportunity to refile the case without having to worry about Presidential immunity from liability for statements he made while in office.
It isn't just former President Trump that does things like this, but his conduct provides good textbook examples of what lawyers worry about when their clients talk about cases that are being litigated.
Social media statements about pending cases by litigants routinely provide powerful evidence against them in trials.
Some clients (particularly politicians and many senior executives of big and medium sized businesses, but also more ordinary people with big egos) are "forces of nature" who can't resist running their mouths, usually to their detriment, when given the least leave to do so. It is easier to teach them to say "no comment" across the board about pending litigation, than to transmit the depth of understanding necessary to comment without saying something potentially harmful. Lawyers spend many hours and sometimes days preparing their clients for depositions for a reason.
Avoiding Annoyance To Opposing Counsel, Parties, And Judges
Making a comment about pending litigation has the potential to aggravate opposing counsel and can emotionally influence non-lawyer opposing parties with whom a negotiated settlement will be reached 90%+ of the time (only about 1-2% of civil cases go to trial, but some are resolved by default judgments or on motion practice as opposed to by settlement).
It can also irritate a judge who frequently prefers to be out of the public spotlight when necessary, even when the statements made aren't prohibited, and judges in the U.S. have lots of discretionary authority.