Why does a firm make profit in a perfect competition market
The first order condition for profits here (with respect to quantity, since firms are price-takers) is
$$p - 4q_i = 0 \implies q_i^* = \frac 1 4 p,$$
which is the supply function of its firm. So market Supply is
$$nq_i^* = \frac{180}{4} p = 45p,$$
and equilibrium market price
$$45 p = 100 - 5 p \implies p^* = 2$$
and equilibrium market quantity
$$Q* = nq_i^* = 180 \cdot\frac 1 4 (2) = 90$$
Per identical firm we have
$$q^*_i = 0.5$$
The profits are
$$(2)*(0.5) - 2* (0.5)^2 = 0.5$$
...indeed.
So what happens here?
Well &quot;perfectly competitive market&quot; among others things means costless and free entry. But the problem above was solved for a fixed number of firms.
At this number of firms, each firm makes an economic profit. This will induce other firms to enter the market, driving equilibrium price down and economic profits to zero.
I guess the OP can understand how one can compute the number of firms required so as to have zero economic profits (hint: it is not finite).