Yes, there are many mechanisms to prevent juries from ignoring the facts or the law.
In the United States, there are several mechanisms in place to prevent this from happening, though there is not always a meaningful remedy in the cases where it does happen.
A legally unjustified acquittal is referred to as "jury nullification," and jurors are screened out based on their willingness to engage in the practice. Lawyers are prohibited from encouraging this behavior, and the court will likely instruct the jurors that they may not nullify. In the event all this is unsuccessful, though, there is little remedy available, as a criminal acquittal is unappealable.
There are more meaningful mechanisms in place to avoid an unjustified guilty verdict or a finding of liability, and they are built into the process from the very beginning of the case, up to the verdict, and into the appellate phase.
At the beginning of a case, a defendant can move to dismiss the charges if the complaint makes allegations that don't actually constitute a crime. This would happen using Criminal Rule 12 or Civil Rule 12.
In a civil case, the judge can terminate the case before it goes to trial using Rule 56 if the evidence is so clear-cut that a reasonable jury could only reach one decision. And if the evidence presented at trial is insufficient to support a particular decision (other than acquittal in a criminal case), the court can either enter a judgement of acquittal (Rule 29) or a directed verdict/judgment as a matter of law (Rule 50); in either case, the court can enter judgment at the close of the presentation of evidence, or after the jury returns its verdict.
And of course, there is always the option of an appeal for a party who believes the jury's verdict was unsupported by the evidence. One could challenge the sufficiency of the evidence, i.e., whether there was any evidence to establish a material fact; or argue that the verdict was against the manifest weight of the evidence, i.e., that the evidence in your favor was so overwhelming that the jury's decision could not have been the result of the application of the law to the evidence presented at trial.
On appeal, though, there will be limited opportunity to actually inquire into the jury's reasons for making its decision. Rule 606 generally prohibits questioning jurors about the basis for their decisions. But in criminal cases, at least, that rule has to give way to Sixth Amendment protections
The Supreme Court confronted just such a case a few years ago in Pena-Rodriguez v. Colorado, 137 S. Ct. 855, (2017). In that case, a man was convicted of sexual assault, but his attorneys learned immediately afterward that a police officer on the jury had explained "I think he did it because he's Mexican," and then offered several stereotypes of Hispanic men as reasons to convict. The trial court refused to reverse the conviction, based on its reading of Rule 606, but the Supreme Court reversed, holding that the Sixth Amendment right to a jury trial requires that the jury is not infected with racial bias:
Not every offhand comment indicating racial bias or hostility will justify setting aside the no-impeachment bar to allow further judicial inquiry. For the inquiry to proceed, there must be a showing that one or more jurors made statements exhibiting overt racial bias that cast serious doubt on the fairness and impartiality of the jury's deliberations and resulting verdict. To qualify, the statement must tend to show that racial animus was a significant motivating factor in the juror's vote to convict.