Hand-wash your swimwear. That's it.
Hand-wash them. The fabric pilling is almost always from the agitation and friction of a washing machine (and the dryer is worse).
Swimwear is delicate — nylon, spandex, elastane blends. A machine cycle beats them up, especially if you toss in towels or anything with velcro. Even on “gentle,” the spin cycle can create enough friction to rough up the fibers.
So: cold water, a drop of mild detergent (or even baby shampoo), gentle squeeze, rinse, roll in a towel to remove excess water, then lay flat to dry. No wringing, no dryer. Do that and your suit will look new for way longer than anyone else’s.
If you hate hand-washing, at least use a mesh laundry bag and skip the dryer. But honestly, hand-washing takes two minutes.
