A lighthouse benefits every ship that passes, whether or not it paid for the light
Economists call something a public good when it's both non-excludable, you can't stop a ship from using the light, and non-rivalrous, one ship using it doesn't use it up for others. That combination means private markets tend to underfund these goods, since anyone can enjoy the benefit without paying for it, which is why lighthouses, national defense, and basic research are classic cases for funding through taxation instead of a market.
— Economic theory, formalized by Paul Samuelson, Public good — The American Economic Review, 1954