Is it right to derive social marginal benefit by adding individual prices instead of quantities? I come across a lecture material on market functions and externalities that makes me quite confused. Here's the setup: Two stores are located next to each other. If one installs a camera system in front of the shop to provide security supervision then it will cover both stores (hence both will be benefited).

The willingness-to-pay functions of these stores for that camera system look like this:



The question is to draw the social marginal benefit function $(SMB)$ of adopting the camera. This is how it is done:



What it does is to add vertically the prices for each level of quantity. Hence for the first part where $P_{WTP2} \ge  0$, $SMB=WTP1+WTP2$. Then after that point $SMB=WTP1$.

What I usually do and see for deriving total demand is to add up quantities for each level of price. Is it because now they are WTP and SMB functions that it's done the other way around?
Vertical summation of the individual marginal benefit curves is the correct way to find social marginal benefit if the camera system, so far as the two stores are concerned, is a public good. Horizontal summation is the way to find total market demand for a private good.
A good is a public good if it satisfies two conditions.  One is non-excludability: that would be satisfied if neither store can prevent the other from benefiting from the camera system.  The other is non-rivalrousness: that would be the case if neither store's use of the system limited the other's use of it.
Even if the camera system covers both stores, it could be that it does not fulfil both these conditions. For example, one store might control its use and limit or charge for the other's access to photos / film taken.  In that case the non-excludability condition would not be met.
Let's suppose however that the conditions for a public good are fully met. Let's also suppose that &quot;quantity&quot; of the camera system can meaningfully be defined (this does not seem straightforward). In that case the quantity must be the same for both stores, and the social marginal benefit at that quantity is the sum (graphically the vertical sum) of the marginal benefits to each store. The principle of vertical summation is implicit in the Samuelson condition for optimal provision of a public good, according to which the quantity provided is optimal where the sum of the marginal benefits equals the marginal cost of provision (Samuelson 1954, see equation 2 p 387 and explanation p 388).
It possibly makes vertical summation seem paradoxical when the vertical axis of the diagram is labelled P for price.  It would be more correct I suggest to label it MB for marginal benefit, as in this diagram illustrating the Samuelson condition.