The GPIO drives the base through 1.8 kΩ, the emitter is grounded, and the collector switches the piezo's lower terminal. R2 limits feed current; R3 sits across the piezo so its capacitance can discharge when the transistor turns off. A passive piezo needs a changing signal such as tone(), not a permanently high GPIO.
For the stated 5 V supply, assumed VCE(sat) = 0.2 V and 220 Ω feed resistor, the switch library computes an initial current-limit estimate of 21.82 mA. At forced beta 10, it requests 2.182 mA base current and selects 1.8 kΩ from E12 below the calculated maximum of 1970.8 Ω. With an assumed 0.7 V base-emitter drop, that resistor supplies 2.389 mA before the small 100 kΩ pulldown current. These are nominal switch-design calculations, not a measured piezo waveform or a universal transistor guarantee.
R3 is 10 kΩ across the capacitive piezo load; omitting it leaves the discharge behavior dependent on the transducer and leakage. Actual acoustic output depends on the piezo's capacitance, resonance, mounting and drive frequency. The feed resistor also affects the waveform. This is not an audio amplifier or a magnetic-buzzer coil driver.
Check the actual 2N3904 E/B/C package order and the controller's GPIO voltage/current limits. A 3.3 V GPIO needs its own base-drive calculation. Connect controller ground to the supply ground. Use isolated-pad perfboard and insulated underside jumpers; no track cuts are needed.