In his treatment of public goods in Principles of Economics, 5th edition, Greg Mankiw gives the standard two characteristics of a public good: (1) the good is non-excludable, that is, a person can not be prevented from using it, and (2) the good is non-rival in consumption, that is, one person's use of the good does not reduce another person's ability to use it.
So far, so good. This is what, I suspect, almost all economists teach.
But then, to drive the point home, he shows these two dimensions in a matrix, with whether it's rivalrous in consumption on the horizontal and whether it's excludable on the vertical. In the "rivalrous in consumption but not excludable" cell, he puts, as an example, "congested nontoll roads." His idea is that if it's congested, it is rivalrous in consumption. That's correct. But he's saying the fact that it's a non-toll road makes it non-excludable. That's wrong. Excludability has to do with whether someone can be prevented from using it, not whether someone is prevented from using it. And by "can," I don't mean, and economists don't mean, the legal idea of "can" but the technological idea. It is technologically doable to prevent someone from using a road. So a road is excludable.
You might argue--and some of my students in the past have argued--that because a law says you can't exclude people, then that makes it non-excludable. But I point out that if that's the case, the government could make things non-excludable simply by not allowing people to exclude others. That's clearly not what economists had in mind in coming up with this characteristic. (It was Paul Samuelson in a 1954 article who stated this idea clearly.) What they had--and have--in mind is that there are no low-cost ways of excluding people.
In short, excludability is a technological characteristic, not a legal one.
My favorite example of a public good is a radio signal before scrambling was invented. It fit beautifully both characteristics of a public good: (1) your tuning into the radio signal did not diminish other people's doing so, and (2) it was prohibitively costly, before scrambling, to exclude people. One delicious aspect of this example is that it shows another thing that economists often want to show: namely, establishing that something is a pure public good does not establish that it can't be provided at a profit. Radio in the United States was, of course, provided at a profit for many decades. I first got this example back in the 1970s, from either Randy Holcombe or David Friedman.