In perfect competition, a firm is a price taker because demand for the firm’s product is perfectly elastic. When you are making a diagram or graph, you represent this with a perfectly horizontal line. When you make a supply and demand graph where the demand curve is a perfectly horizontal line (as seen in the link below), you will see why the firm is a price taker.
In perfect competition, the firms’ goods are all homogeneous. That means that no firm’s goods are better than those of any other firm. Because of this, no consumer will buy one firm’s goods at a price higher than the market price. There is nothing about a firm’s goods that make them worth a higher price. If a firm raises its prices, no one will buy from it.
You can see this in the graphs in the link. The demand curve only intersects the supply curve at one price level. If the price is at any other level than the one represented by the demand curve, there will be zero quantity demanded. Therefore, the firm is a price taker and can only charge the market price.