Charles’s Law states that, at a fixed pressure, the volume of a given amount of gas is directly proportional to its temperature. This means that if the temperature of a gas increases, its volume should as well.
By leaving an air gap in the syringe barrel, you trapped a fixed amount of gas. Initially, the system is balanced, and water will not move in or out of the syringe unless there’s a new force. When the trapped air increases or decreases in volume due to a change in temperature, water acts as a piston, moving in or out through the tip until the pressure is equalized.
You should have noticed that the volume of air in the syringe barrel changed when you brought it to a different temperature. By plotting volume versus temperature on a graph, you may also have noticed that the points tend to line up along a straight line. You could represent the equation of the line as V = kT, where V is the volume, T is the temperature, and k is a constant (the slope of the line). This is the mathematical representation of Charles’s Law.
Charles’s Law can be combined with Boyle’s Law (which relates pressure, P, and volume, V), Gay-Lussac’s Law (which relates temperature, T, and pressure, P), and Avogadro’s law (which relates volume, V, and the amount of gas in moles, n) to form the ideal gas law: pV = nRT.