This phenomenon is called the 'tragedy of the commons' (c).
In a situation where a community shares a resource, the tragedy of the commons is when individuals collectively deplete the resource following their self-interest and going against the common good. It was theorized in 1833 by British economist William Forster Lloyd, but only became a widespread concept over a century later.
"The commons" refers to the shared resources.
Nowadays, this concept is used in the debate around global warming and environmental preservation, with the example of over-fishing, among others.