Why not an even value, such as 130 mm?
Neat Numbers Don't Kill The Enemy
The general answer to that is because the design goal is to make the best gun possible, not have the numbers come out neatly. The engineers designing and building the gun don't care if it's in neat numbers. They might start with one neat number, but derived dimensions are subservient to engineering considerations and calculations.
Use What's Available
This is probably the most important reason why large caliber guns are the caliber they are: there's already tooling to produce the parts in that caliber, particularly the expensive rifled barrels. For example, the German 12.8 cm Pak 44 used tooling in common with the 12.7 cm SK C/34 naval gun used on German destroyers.
Then there's ammunition commonality. Just having the same caliber doesn't mean you can share ammunition, there's many other considerations, but it helps. If all your guns can share ammunition that simplifies production, logistics, and supply.
For small arms, small differences in ballistic performance are not terribly important; tactics dominate small arms engagements. Instead the problem is supplying large amounts to large numbers of troops who will use it for various tasks, and they have to carry it. Logistics becomes paramount. For this reason, most militaries, in contrast to civilians, have standardized around just a few small arms rounds. One pistol round (9x19mm or 9×18mm), one intermediate round (5.56x45mm NATO or 5.45×39mm Soviet), and one full power rifle round (7.62×51mm NATO or 7.62×54mmR).
Large caliber firearms tend to be specialized, vehicle mounted, and fire less ammunition. They fill the roles of anti-tank, anti-aircraft, and artillery. These fields were in an intense arms race, particularly during WWII until roughly the 1980s when electronics took over, so you could get an advantage out of fielding a new round that offset the logistical problems. As a result militaries can afford a lot of diversity in large calibers, but they still tend to cluster around certain historical calibers that they (or who they're buying from) are already producing.
Adapted From Quirky Old Naval Guns
Large caliber artillery and tank cannons are often adapted from naval guns and anti-aircraft guns (which also often come from naval guns). Both naval and anti-aircraft guns require long range, high muzzle velocity (naval guns for armor penetration, AA for altitude), and large calibers to pack sufficient explosive or kinetic energy to do damage. Anti-aircraft guns are often preferred because they're designed to be lighter, and more mobile than naval guns.
Naval guns have been around for a long time, so tanks and artillery inherit the naming and size quirks of old naval guns.
For example, the famous German 88 began life as AA gun which itself began as a naval gun. The US 90mm also started as an AA gun (the 90mm M1 and M2) and was adapted into the M3 tank cannon for the M36 Tank Destroyer and M26 Pershing.
It's Just A Name
There are various ways to name a round. Wikipedia puts it this way.
Due to variations in naming conventions, and the whims of the cartridge manufacturers, bullet diameters can vary widely from the diameter implied by the name.
There are so many numbers to choose from! Have a look at 5.56x45mm NATO.
Look at all those numbers to choose from! You can use the chamber diameter, the case diameter, the bore diameter, the bullet diameter... If rifling is involved, you can use the diameter as measured at the lands (the smaller diameter formed by the ridges) or the grooves (the larger diameter formed by the troughs between the ridges). For example 9x19mm Parabellum and 9x18mm Makarov do not have the same bullet diameter. 9x18mm Makarov measures caliber between the lands, so the bullet is 9.27mm in diameter. 9x19mm measures between the grooves, so the bullet is 9mm in diameter.
And you can just make shit up.
For example, no part of 5.56x45mm NATO is 5.56mm. The bullet is 5.70mm at its thickest, same as its parent the .223 Remington. 5.70mm is .224" so even the .223 Remington isn't .223". The closest thing to 5.56mm about 5.56mm is the pilot diameter, which is the size of the hole which guides the bullet into the rifling, and even that isn't quite 5.56mm.
So the number in the name is just a name, divorced from the actual engineering specifications.
Inches, Pounds, Millimeters
Sometimes odd metric designations are because they began life in another measurement. 12.7cm and 12.8cm are actually 5 inch guns. 76mm is 3 inches, etc...
Then there's the British "pound" system like the "3-pounder". This is how much round, solid shot would weigh and goes waaaaay back in British naval history. A 3-pound gun is 47mm which explains why we had 47mm weapons.
Volume Is The Square Of The Caliber
When you increase the caliber, and keep the length the same, the volume of the case increases by the square of the caliber. That means bigger shells (now you can store less shells), more weight (good luck humping that round, loader), and more material (higher cost per round).
Using your example of going from 128mm to 130mm, the brass case of a Mark 10 shell for a US 5"/38 gun is 127x679mm and weighed 5.58kg. A shell case is an open topped cylinder with a surface area of 2πrh + πr^2. 127mm is 283,433 m^2. 130mm is 290,434 m^2. That's an increase of 2.5% or 140 grams of brass (probably more since the base is thicker than the walls). Volume is πr^2h and goes up by ~5% which means more powder.
The numbers get worse for the barrel. The 5"/38 is 5683mm long and weighs 1,810 kg. If we increase its surface area by 2.5% that's an extra 45 kg of high quality steel. That extra weight means a stronger mounting which means more weight which needs stronger drives to rotate it, etc.
Note that these are very back of the envelope calculations. Point is, even a small change in diameter can have a large effect.
Please keep in mind this is not a practical example of scaling up a round, I deliberately left the length the same and ignored a host of other issues because they're outside the scope of the question. It's only rough calculations intended to illustrate the knock-on effects of changing the caliber even by a few millimeters. And yes, as the caliber (radius) changes, but the length remains the same, the volume changes by the square of the caliber; that is not a mistake. If you want to edit it with more accurate calculations that don't clutter the answer, please do. If you want to talk about this more, please do it in chat.
Specific Calibers
Many caliber names trace back to the 1890s up to WWI when changes in gun and ammunition was happening fast, and nobody fussed too much about naming standards because they needed guns for the front NOW.
Others are simply their metric versions of older imperial standards.
155mm
Roughly 6.1 inches. This traces back to the French WWI Canon de 155 C modèle 1915 Schneider which took an earlier 152mm (6 inches) and upped it to 155mm (6.1 inches). Why switch to 6.1", I don't know.
152mm
6 inch naval gun.
12.7/12.8cm
The ubiquitous 5 inch naval gun.
105mm
Roughly 4.1 inches. Traces back, in German service, to the 10.5 cm Feldhaubitze 98/09 from 1902.
102mm
4 inches.
90mm
3.5 inches.
88mm
Possibly from the British 25-pounder (not the Ordnance QF 25-pounder from the 1930s, but the caliber measurement). The 88 in German service is originally from the "quick firing" 8.8 cm SK L/30 naval gun dating back to 1892.
76mm
3 inches or 17-pounder.
75mm
From French Canon de 75 modèle 1897. Adopted by the US to have commonality with French equipment in WWI.
57mm
6-pounder.
47mm
3-pounder.
I can trace this back to the 18th century Grasshopper. In modern times it began with the QF 3 pounder Nordenfelt and the Canon Hotchkiss à tir rapide de 47mm, quick-firing naval guns both designed in 1885.
45mm
AFAIK only used by the Soviets. They scaled up a German 37mm anti-tank gun in 1932 to make the 45 mm anti-tank gun M1932 19-K. According to Wikipedia 45mm was chosen because...
The reason for selecting 45 mm caliber was the large reserves of the French 47 mm shells which can be converted to 45 mm by milling out the driving bands.
Why they chose 45mm instead of 47mm I'm not sure.
40mm
2-pounder.
37mm
1.5 inch, and 1-pounder.
Earliest modern use I can find is the QF 1-pounder pom-pom 37mm autocannon from the late 1880s.
25mm
1 inch.
Earliest reference I can find is the French 25mm Hotchkiss anti-tank gun proposed in 1926 to replace the 37mm infantry gun with better armor piercing capability. The Japanese used a local variant as the Type 96 25 mm AT/AA Gun.