My question is why are there portions of the barrel that are thicker, is this purely to lower the weight of the cannon or is there some reason that the additional strength is needed.
The barrel is thickest in the area where the explosion of the powder takes place because that is where the greatest strength is needed. That diameter could be extended all the way to the muzzle but that would make it much heavier and more unwieldly without adding useful strength (it would also add to the cost of the piece.) Consequently the barrel diameter gets smaller as one advances toward the muzzle.
I was going to build a cannon that used a basic piece of 1.25 inch rebar to make a 3/8 bore cannon. Are these thicker walls needed to make a safe cannon?
1.25" stock for a .375" bore is fine, although I would buy a piece of 1018 cold rolled steel instead of using rebar. It is my understanding that rebar is sized to provide a nominal strength as opposed to providing a material with nominal properties. In other words, a piece of rebar will have a tensile strength of 10,000 lbs whether it takes a diameter of .300" or .320" to achieve that strength whereas a piece of 1018 will have a strength of 50,000 psi whether it is .375" in diameter or 1" in diameter.