Control 5 V buzzer using 5 V microcontroller (which can't drive it directly) and a single 5 V power supply?
Thank you for posting and linking to exactly which sound-maker you are trying to use: the PB-12N23PW-05Q self-oscillating buzzer.
(If you had a raw piezo disk, or a coil speaker, we would use a different drive circuit).

If you insist on using a NPN such as the BD237, you need to add a external resistor between the MCU and the base of the NPN, as joeforker mentioned: 1 KOhm should be adequate.
But no matter what resistor or silicon NPN transistor you use, you will end up with (at best) a V_ce_sat voltage drop of around 0.6 V, so the voltage across the buzzer is about 4.4 V -- which is technically outside the "guaranteed-to-work" "4.5 to 5.5 V" operating range in the buzzer datasheet.

If I were you, I would probably throw out the NPN and replace it with a MOSFET.
A cheap 2N7000 has an on-resistance of 5 Ohm; at 25 mA that gives a voltage drop of .125 V.
(More expensive MOSFETs have an order of magnitude less (better) on-resistance).

The MOSFET should work in the circuit you posted -- it doesn't need a resistor.

I am surprised that you are getting a different sound.
The kinds of mistakes I am likely to make (and so the first things I would check) are:


Did I put the buzzer in upside down?
(This doesn't matter much for a raw piezo disk, but it does matter in a self-oscillating buzzer like yours).
Hook the buzzer up to a bench power supply, and see what it sounds like in the 4 V to 5 V voltage range. Perhaps it's supposed to sound like that at that (5V - transistor drop) voltage?
What is the actual voltage across the buzzer and across the transistor?
I might check this with an O'scope, since it's quite possible that we have an average current of 25 mA, as shown on the graph, but peak pulses of much higher current -- perhaps such a high instantaneous current that your so-called "5 V" power supply is briefly pulled down to such a low voltage that your ATmega resets.
If that is the case, you'll need to add some bypass capacitors and perhaps a ferrite bead or resistor.