The pitch depends on the vibrating air column inside the bottle.
Key physics: It's a Helmholtz resonator. The frequency f ≈ (v/2π) × √(A / (V × L)), where v = speed of sound, A = neck area, V = cavity volume, L = effective neck length.
Identical bottles + same water level = same note. Different shapes or water levels = different notes. This principle lets you "tune" bottles to play melodies (e.g., "bottle music" videos).