Hello! It sounds as though your dog has been very unlucky and had lymphoma diagnosed, from a biopsy. You could ask your vet how certain they are about the diagnosis, but presumably if they have come to you with this diagnosis, they will be confident. Lymphoma can cause signs such as diarrhoea and weight-loss, although that depends how early it is caught; I have even diagnosed lymphoma in dogs whose only clinical sign was a very large lymph node that I found during a routine examination.
Animals with lymphoma can have low immunity (they have excessive immune cells but cancerous immune cells don't always get the job done). This can make them more likely to prevent with minor illnesses such as worms. We call this a secondary effect. It is true that worms can also cause intermittent diarrhoea, but I trust that the diagnosis you were given was not only because of the diarrhoea (there are many, many causes of diarrhoea), but from pathology tests. In real life in developed countries, worms only very rarely cause weight-loss in fully grown, healthy animals. I would expect the lymph node microscope pathology in diarrhoea caused by worms to be different from the histology in a lymphoma case.
However, I don't know the details of your dogs' presentation and I am not your vet. Lymphoma is understandably a hard diagnosis for owners to take in so your vet will not be surprised if you call back with more questions. There is a site called the RALPH site for owners of pets who are facing unexpected illness or grief; they are also a brilliant resource.
One of my colleagues has written a blog that includes lymphoma in dogs:
https://vethelpdirect.com/vetblog/2021/04/12/why-are-my-dogs-lymph-nodes-enlarged/
Best of luck.