If firms in perfect competition all pay the same price for resources and all receive the same price for outputs, how can they have different total profits or different profits per unit sold?

The cost and skill of the available labor pool differs widely from place to place. Some comnpanies utilize advertising better than others. Some are willing to invest more to reduce labor costs.