It's strictly random what abilities you get, but each brand has one ability that it has a higher chance of rolling. For example, Krak-On gear has a greater chance of rolling Swim Speed. So when you see triple sub gear, it's most likely that they got it on a brand that favors that ability as you have better chances of rolling a triple of a particular ability if you do it on the corresponding brand.
Generally it just comes down to luck and hoping you get it naturally or hoping you can do it in as few rerolls as possible, and trying to make it work in your favor by using gear with the brand that's more likely to get the ability you want. Another method people use is save-scumming, which allows you to effectively have infinite rerolls through save manipulation.