Azerane gives good advice. You often need to try several things in order to sort this type of problems. For many bunnies, it’s about not eating enough hay. For some bunnies you need to cut back on the pellets or switch to a different type. Our dietary requirement change over our lifespan and it’s the same with bunnies, a young rabbit needs richer food than an adult and an elderly rabbit can have difficulty absorbing nutrients. As Azerane says, bunnies can be sensitive to greens, too much greens (what’s “too much” it’s individual) or one or a few particular greens. I have a bunny who’s sensitive to carrots, he can’t tolerate the snmallest piece.
Bunnies definitely can get worms, but it is rare in house bunnies. Outdoors bunnies or bunnies allowed to graze outside are likely to get worms though. But the problem is more often a dietary issue. There are probiotic supplements you could try, in the USA there’s Benebac, in Europe there’s Pro_fibre rabbit. There may be other brands that are just as good, just make sure it’s suitable for herbivores so it doesn’t have dairy or some type of meat in it (as the case can be with probiotics for cats and dogs).