The article seems to state the legal standard which I repeat here in a Google Translate version:
The former Government delegate for Gender Violence, Miguel Lorente ,
defines vicarious violence as "violence that, when it seeks to hurt
and harm women, instead of doing it directly, seeks to harm people who
have special meaning for them."
Harming a child or other person with special meaning to the true target of the violence is, of course, already a serious crime in Spanish law.
A finding that the crime was a form of vicarious violence is a sentencing enhancing finding of fact by the court that makes a convicted defendant eligible for what U.S. lawyers would call "life in prison with possibility for parole" even though Google Translate provides a more literal translation from the Spanish of the words used to describe the enhanced sentence for which someone becomes eligible if this is established.
Of course, there are other reasons why some people might hurt their
children, such as part of a pattern of abuse toward the children
unrelated to spousal abuse, for the purpose of collecting life
insurance money, as part of sexual abuse, and so forth, so presumably
there exist certain criteria in the Spanish legal system to
distinguish these cases.
Other than the legal definition set forth above, there does not appear to be any further legal guidance for the courts in determining if this sentence enhancing fact has been established. It is merely a question of fact for the judges on the court to determine based upon the evidence presented at trial by the prosecution and reasonable inferences from that evidence.
Lawyers for the defendant can argue that this sentence enhancer should not apply because one of the different motives in the quoted material from the question was the actual or predominant motive, and the prosecution can argue that it was indeed vicarious violence, and then the judges have to decide whether they think that the prosecution has met its burden of proof to establish this motive and impose the enhanced sentence (which is authorized, but not required, even if it is established).
This isn't going to be the easiest point to make in a typical case for the defendant.
Usually, the defense is primarily going to be trying to cast doubt upon whether the prosecution has met its burden of showing that the defendant is guilty of the underlying crime at all, and, for example, having the defendant testify that he did it because he was a pedophile, rather than to hurt his wife is not going to help him all that much.
Instead, I would expect that the usual approach of the defendant's lawyer would be to argue that the prosecution's evidence, if believed, supports a prosecution theory of the case that, for example, this murder was about insurance money and not about intimidating the defendant's wife.
Another way the the defense could fight this sentencing enhancing claim at trial would be to argue that the specific evidence of the prosecution offer to show the defendant's alleged vicarious violence motive isn't credible in all of the ways the one generally casts doubt on the credibility of evidence in a court case. For example, the defense might offer evidence from a different witness than one offered by the prosecution that cast's doubt on the credibility of the prosecution's witness. Or, the defense might ask (or have the judges in the case ask) questions of the witness who is the key witness on the vicarious violence motive issue, that casts doubt on that witnesses' own testimony (perhaps by pointing out contradictions in the testimony or that the witnesses couldn't have been where the witness claimed to be in earlier testimony).
Also, it doesn't appear that vicarious violence has to be an either/or question. Nothing in the definition of vicarious violence suggests, for example, that a defendant can't both have a motive to collect insurance money, and a motive to intimidate the child's mother, at the same time, "killing two birds with one stone" so to speak.