united-states
Messaging (and other online communication) are fixed media.
A face-to-face conversation, or a telephone call, does not exist at all - except in the mental recollections of the participants. And those are always very problematic as evidence, because people's recall is inaccurate.
Whereas communication in a fixed medium is durable: a newspaper, a sound recording, security camera footage. It stands on its own and can be examined by experts.
What catches a lot of people off guard about the Internet is they are mostly fixed media.
Prior to the Internet, investigation of harassment almost entirely depended on anecdotal evidence. It was difficult to prosecute cases which were entirely based on the victim's word. The closest any of this came to objective evidence was a polygraph, and that wasn't reliable. Of course we want bona-fide victims protected, but what keeps a malicious actor from putting someone else in jail with words alone?
Now with the Internet, much of the evidence is rendered in fixed media. This is a "breath of fresh air" for such prosecutions!
However, just like any other physical evidence, it must be brought into evidence by the testimony of persons, and that testimony gets to be cross-examined. And this is where your concerns about provenance get addressed. A party will assert that the messages are forged, and that will be examined.
The validity of evidence is itself on trial.
There are two evaluations: first whether the evidence is even valid enough to present to a jury, and evidence that makes the cut is then examined and cross-examined in front of the jury.
Keep in mind that contrary to TV drama, there's no "surprise evidence". Almost any evidence - and certainly ALL evidence in a fixed medium - must be shared with the other party long before trial. Pre-trial, it will be challenged, the phone/device subpoenaed and turned over to experts for analysis. If it is evident that the party "has conveniently deleted or lost" the material, the evidence will be thrown out. And if the party is proven to have falsified the data, they're in much worse shape.
A lot of chat services keep chat logs on the server/cloud, in the clear. Getting those is as easy as subpoenaing them, and that will be a canonical answer because the ISP would have no reason to lie.
For a service where chat logs are kept in the clear only by individuals who choose to keep them, then "reading those logs into evidence" will involve a cross-examination of the parties involved as to their honesty and motivations.
I don't know what and how WhatsApp stores when they log chats, so I don't know if there's any cryptographic information there that could be authenticated. But certainly if "he" presents one chat log, and "she" presents a different chat log, then we're clear around to "he said, she said". But all of it together can be examined.
For instance, linguists can look at other chats, discern the writing styles of each party, and then look at the disputed lines and examine who is more likely to have written those. And they give testimony on that.
So it is evidence, but it gets two rounds of possible challenge: First as to whether the evidence is reliable enough to even present to the jury, and then experts testifying in front of the jury their opinion of its reliability.