Dave VanHorn says
Driving a piezo from a micro usually follows a pattern..One lead grounded, one lead to the micro. Too soft.
Both leads to the micro, driven in opposition. Nice and loud.
Then the strange behaviour begins.
After a while, you notice the similarity in the schematic between a charge pump voltage doubler and your piezo element and port pins, and you realize that every time you flip the piezo, you are flirting with SCR Latchup or glitching your micro.
Then you drive it through a pair of HC inverters at least, and get "happy beeps"