For example: Early Panzer 4 vs Panzer 4 F2 and up, StuH vs StuG, field howitzers like the LeFH 18, etc... .
On tanks and armored vehicles, shells intended for attacking targets other than tanks were High Explosive (HE) shells. HE shells of the time weren't designed with penetration in mind - after all, many of these guns were adapted from field artillery pieces, and an HE shell from a typical howitzer penetrating what it hits merely means that it sinks into the ground and wastes all of its energy in the earth when it detonates. Instead, HE shells rely on the force of the explosive filler within them to do the damage. The power of the explosive is independent of the velocity of the round, meaning lower velocity guns can be used, and low velocity guns are generally easier on the mounting (due to less weight and recoil) and can allow for a degree of plunging fire depending on the specific design. An added bonus is that, for most of these low-velocity howitzers used on various armored vehicles in WW2, they used barrels significantly shorter than a corresponding anti-tank derivative, as the added muzzle velocity from a longer barrel provided negligible benefit, meaning weight was kept down.
Armor Piercing (AP) shells, on the other hand, tended to less explosive filler and a hardened case, as they relied on their kinetic energy to break through armor before detonating the charge. Because kinetic energy is so important, the velocity of the shell becomes a significant factor, in turn requiring a longer barrel to give the shell more time to accelerate.