Why do externalities lead to a Pareto-inefficient outcome?

So we know that under a Pareto-inefficient outcome, there is room for Pareto improvement, i.e. making someone better off without hurting anyone.

Assume that there is a drug company which is in competitive equilibrium: and $$N^S=N^L\\ |MRS|=|MP_n|=|MRT_{(c,l)}|$$ $\pi$ is maximised etc. So everyone should be happy right? Since we are in a competitive market,

But if this drug company makes some pollution which is a threat to the health of citizens, we call this case a negative externality.

By definition if such negative externalities exist, even though we are in a competitive equilibrium, we would be Pareto inefficient.

But how come we are Pareto inefficient? If we reduce the pollution somehow and reduce the externality, or create a market for pollution and let the pollution trade the firm would definitely be losing money since it would pay for the pollution. So isn't it impossible to make citizens better without making the firm worse off?