The cannons on ships are named for the size of shot (cannonballs and other) that they can fire.
A “4-pounder” can fire a 4 pound cannonball, and a “24-pounder” can fire a 24 pound cannonball.
The standard cannonball sizes for the Royal Navy are as follows (in lbs): 4, 6, 9, 12, 18, 24, 32, and 42.