Objection (United States law) has goal prevention
In the law of the United States of America, an objection is a formal protest raised in court during a trial to disallow a witness's testimony or other evidence in violation of the rules of evidence or other procedural law.  An objection is typically raised after the opposing party asks a question of the witness, but before the witness can answer, or when the opposing party is about to enter something into evidence. The judge then makes a ruling on whether the objection is "sustained" (the judge agrees with the objection and disallows the question, testimony, or evidence) or "overruled" (the judge disagrees with the objection and allows the question, testimony, or evidence).  An attorney may choose to "rephrase" a question that has been objected to, so long as the judge permits it. Lawyers should make an objection before there is an answer to the question.Objections in general
An attorney may also raise an objection against a judge's ruling, to preserve the right to appeal that ruling. Under certain circumstances, a court may need to hold some kind of pretrial hearing and make evidentiary rulings to resolve important issues like personal jurisdiction, or whether to impose sanctions for extreme misconduct by parties or counsel. As with trials, a party or their counsel normally raises objections to evidence presented at the hearing in order to ask the court to disregard impermissible evidence or argument, as well as to preserve such objections as a basis for interlocutory or final appeals from such rulings.
Objections are also commonly used in depositions during the discovery process to preserve the right to exclude testimony from being considered as evidence in support of, or in opposition to, a later motion, such as a motion for summary judgment.