Trying to make a bluetooth connection between an ultrasonic sensor and a buzzer

mySerial.println("a");

This line of code is sending the character 'a' and then a carriage return ('\r') and new line ('\n') character.

What do you think happens with the buzzer when the carriage return and new line characters are read by the receiving code.

if (mySerial.read() == 'a')
{
sound = 2000;

}
else
{
digitalWrite(buzzer, LOW);
}

For best results in getting help on the forum you should post your code as a "code section" which is formatted and can be easily copied.

https://forum.arduino.cc/t/make-experienced-users-help-two-ways-to-quickly-post-code-as-a-code-section/937298