Why USB power banks tend to have much larger capacity than cordless tool batteries?
A graphical representation may help.

Figure 1. The energy capacity of a battery is the product of the battery voltage and the mAh rating.
Here it's clear that the 18 V, 5 Ah battery has the higher capacity.
The Wh (watt-hour) rating is a better number to use when comparing battery capacities.