There are three main differences between both rifles and pistols, on the one hand, and shotguns on the other. The first major difference would be that of the construction of the barrels. In shotguns, much like in ancient cannon, the bore in which the projectile travels and eventually leaves the gun is smooth and lacks any sort of rifling. Rifling, or the grooves cut in the inside of a rifle or pistol barrel, is used to give the bullet spin. And by giving a bullet spin, one gives the bullet accuracy. Except for cases in which shotgun barrels are specifically manufactured to shoot slugs and therefore rifled (to be used for deer hunting in certain areas), all shotguns are smoothbores.
Another main difference between said firearms is that of the projectile which they shoot. Rifles and pistols shoot bullets, or solid metal projectiles usually made of lead and more often than not jacketed in some fashion by copper. Bullets come in different calibers and are made larger or smaller, and by proxy heavier or lighter in weight, for their intended target. Except in the case of shotgun slugs as mentioned above, shotguns shoot many small round metal pellets, collectively and singularly called "shot," instead of a single projectile. A musket could be used in the same way: fill the barrel with the required powder charge and proceed to fill the barrel with whatever one could find to stuff in it and off you go. A shotgun is meant to produce a great deal of damage one little bit at a time and to cover a wider area than a single bullet in order to deal this damage.
The third and final difference between the aforementioned firearms is that of how one measures the bore. The bore is the internal diameter of the barrel in which the bullet or shotshell's contents travel from the cartridge to the target. For those in the UK, a shotgun "bore" is the same thing as we in America call the "gauge"; and by gauge, I mean the measurement of the diameter of the internal part of the barrel(s) themselves, excluding the choke. Except in the case of the .410 bore, all shotguns are measured not by their diameter in inches, as are rifles and pistols, but by another measure entirely.
Shotgun gauge is measured by the amount of spherical balls that fit the diameter of the bore which equal one pound in weight. Once done, the resulting number of balls is the resulting gauge. Please recall that I mentioned ancient cannon. The reason for measuring gauge in this way is because in ancient times, cannon, too, was also a smoothbore. In the case of cannon, which also fired spherical shot in a smooth barrel, one measured the size of the cannon by the amount of weight that comprised the cannonball. Thus, a 10 pound cannon shot a 10 pound cannon ball. This 10 pound cannonball was of such a diameter that a relationship could be established: all 10 pound cannonballs could be made and be loaded into a 10 pound cannon, itself which had a certain diameter. So, too, it was with muskets. Obviously not as large as cannon, muskets were also referred to by the weight of the projectiles they shot. Because of their diminutive size compared to cannon, one had to fit a smaller projectile into a smaller tube. Therefore, the old way of measuring what kind of bore was being used was turned into fractions of a pound in weight. Thus, if a musket shot a spherical projectile that was 1/16th of a pound, it was called a 16 bore because it would take 16 such projectiles to equal one pound in weight. And in America, the 16 bore was translated into the 16 gauge.
Since modern day shotguns are the direct descendants of ancient cannon and muskets, it is no wonder that shotguns are measured in this way.