Adding to Bill Clark's answer, imagine that in addition to entry/exit decisions, you add to your model the decision to merge with another firm. When economies of scale are present, there are circumstances in which two companies that are considering exit might instead choose to merge, yielding a firm that has a relative advantage in terms of marginal costs.
As soon as this happens, the equilibrium condition for a perfectly competitive market vanishes (entry and exit until demand is satisfied by a market of firms for which MC = p). A simple way to see this work would be to set up a Bertrand price competition model with three firms: one whose marginal cost is lower than the other two. In addition to the entry/exit decision, allow for a merger decision if the resulting combined marginal cost function results in winning the Bertrand game (which it may do if economies of scale are present). You'll be able to show that there are conditions for which the two inferior companies find it optimal to merge rather than exit, capturing the whole market.