The question considers why in perfect competition the demand curve is assumed to be perfectly elastic. More specifically, this assumption refers to the firm’s demand curve in a perfectly competitive market, rather than the overall demand curve for the market as a whole.
The first step is to define the term elasticity. This is a mathematical concept relating quantity demanded to price. Specifically, it is defined as the percent change in quantity (demanded) divided by the percent change in price. As such it is mathematically related to slope, but is not equivalent. “Perfect” elasticity is applied to the situation in which the demand curve is horizontal, i.e. slope = 0. Mathematically, this would imply that the amount of output which the firm may sell at the given market price is effectively infinite. More accurately, the firm may sell all of the output of which it is currently capable at the given market price.
The key feature of this situation is that the firm is a perfect price taker, rather than price maker. That is, offering output at a price lower than “market” would not result in additional sales, and offering it at a price higher than market would result in no sales whatsoever (i.e. all buyers would simply go elsewhere rather than pay the higher price). In a perfectly competitive market, ALL firms are in this same situation. The market price is established, at equilibrium, by the cumulative interaction of all buyers and all sellers in some type of auction/open market process. This requires that the good or service in question is perfectly homogeneous between producers (e.g. wheat of a certain grade) such that one supplier’s output is literally indistinguishable from any others. Other assumptions include that switching from one supplier to another is completely costless for any and all buyers.
Note that this condition is largely hypothetical. Truly perfect competitive price equilibrium rarely occurs. Most markets are typically in motion, always searching for new equilibrium in reaction to the latest change in conditions. Also, only certain commodities meet the requirement of homogeneity, and suppliers are constantly trying to create the perception if not the reality of product differentiation so that they can, in fact, exercise some control over price.