This takes some research, but much of it is just common sense. Look for companies with proprietary databases, distribution networks, or exceptionally high levels of customer service, all of which are hard for competitors to duplicate. Drug companies can do well in the competition cut, because their patents afford some protection for high-margin drugs. Technology companies are more vulnerable. Sure, there are patents, but newer technologies often sweep in to make them obsolete.
Market share is also an important attribute.
The biggest players always have more control over the pricing of their products. Second-tier competitors end up having their prices set by the leaders, an unfavorable position to be in. The pressure to show strong revenues and profits leads companies into aggressive bookkeeping. That can work for a while. Investors can protect themselves somewhat against such surprises.