Cannons with long barrels penetrate their target better, and have better velocity/range than short barrels. Therefore, I don't understand why there weren't more long barreled cannons (World War 1 - beginning of World War 2). Ive seen tanks, and even artillery from World War 1 with so short barrels that you can barely see them. Do short barrels have some advantages I don't know about?
Cannons with long barrels penetrate their target better, and have better velocity/range than short barrels.
This is only true given proper loads. At a certain point additional length with the same load will give no benefit to velocity (in fact it can reduce velocity).
Ive seen tanks, and even artillery from World War 1 with so short barrels that you can barely see them. Do short barrels have some advantages I don't know about?
A big one is weight. Long guns designed to fire heavy shells weigh a lot, and early tanks simply couldn't handle it. As it stood, many WWI tanks were extremely slow because automotive technology was still young.
Also mobility, famously British Hotchkiss naval cannons were mounted to each side of the Mark I. These proved too long and could impede mobility, so they were shortened and lightened from the 8cwt to 6cwt in later models.
On these points recognize that the British Mark V only had 150hp (45 more than the Mark I) and had a top speed of 5mph . A modern Ford Focus has more power than WWI tanks.
Another thing to remember is that the intention of many early tanks was to fight and break infantry units, and were thought of as "a “gun with a certain degree mobility” to be primarily employed for infantry support" (Castaldi, et al). Tanks were equipped with smaller guns because that's all they needed for the job. Weapons are designed to do a specific job, and more power or accuracy isn't always needed. If a gun can do basically the same job while using less resources and weighing less, the cheaper, lighter gun will often be preferred.
Castaldi, Carolina, Roberto Fontana, and Alessandro Nuvolari. "‘Chariots of fire’: the evolution of tank technology, 1915–1945." Journal of Evolutionary Economics 19.4 (2009): 545-566.
Penetration isn't everything. Most artillery and tank fire in fact consisted of high-explosive shells, where the weight of explosive was the prime determinant of damage done.
Long barrel high-velocity guns in fact tended to have worse high-explosive shells, because such guns needed strengthened shell casings to withstand the higher velocity and thus reduce the amount of explosive delivered.
Perhaps you are confusing long artillery with mortars?
Here is a picture of a Civil War era mortar.
Here is a picture of a Civil War era howitzer (cannon).
From http://www.civilwarartillery.com/basicfacts.htm:
Guns and howitzers differed in several aspects. A gun was a long-barreled, heavy weapon which fired solid shot at long range with a low degree of elevation using a large powder charge. A howitzer 12-pounder Howitzer had a shorter barrel and could throw shots or shells at a shorter range but at higher elevation with smaller powder charges. Howitzers were lighter, more maneuverable weapons than guns.
...
Mortars were stubby weapons which fired heavy projectiles in a high arc. Only a small powder charge was needed to project the shot or shell to its maximum elevation.