No, tubes and tires don't need to match exactly. Tubes are made from butyl rubber which can stretch. Bike inner tubes will accommodate a limited range of sizes. Larger tubes may be more susceptible to getting pinched between the tire and rim.
Does tire width matter for tubes?
While your diameter measurement needs to be exact, your width measurement does not. Because inner tubes stretch, they typically come in a range of widths. For example, one of our most popular tubes is the 26 x 1.75-2.125” which means it fits a 26-inch diameter tire with a width in the range of 1.75 to 2.125 inches.
Can I use a wider inner tube?
Can I use a smaller or bigger inner tube than the tire? An inner tube that is 10 millimeters or half an inch wider or narrower can be used as long as it matches the rim diameter. A 700×25 inner tube works in a 700X32 tire, but in a 700X45 could experience issues.