railroad numbers its locomotives in order 1..N. One day you see a
locomotive with the number 60. Estimate how many locomotives the
railroad has.
The example concerns with so called German tank problem. From what I see, Allen B. Downey does not suggest that taking mean of posterior distribution enables us to calculate posterior probability. The problem is about guessing the number of locomotives given only the information that there exists locomotive numbered 60. Bayesian analysis of this problem leads to using this data and uniform prior to obtain posterior distribution. The "best guess" about number of locomotives is the mean of this distribution. In this case we are not interested in probabilities, or distribution of the parameter of interest, but about point estimate for it. Mean of posterior distribution is one of such point estimates we can use.
As mentioned in the comments and in @peuhp's answer, in this case mean minimizes L2 norm (squared difference), but we could choose different estimators as well, e.g. median that minimizes L1 norm (absolute difference), mode that minimizes L0 norm etc. All this depends on the loss function that you want to minimize, i.e. the criteria that you use to choose when deciding on what is the "best guess".
You could be interested also in reading about maximum a posteriori estimation.