You named the other object as gameObject, which is the name of a property - this may have confused the poor compiler’s brain and made it read the property gameObject instead of the variable you’ve created. Anyway, it’s a really bad idea to give the same name to different things, so I renamed the variable to otherObj. This code must be placed in the script attached to the same object as the audio source (NOT the player!):
This will play the object’s sound when the object tagged “player” touches the trigger, and will stop when other object enters the trigger or the sound finishes (Play only plays continuously if loop is set!).
NOTE1: the tag available in Unity is “Player”, not “player” - make sure your tag is correctly spelled, or it will never work;
NOTE2: check if there’s some other instance of this script attached to the player - it could produce the problem you mentioned.
Problem here is that there is nothing to stop the sound from playing until something that is not a player enters your trigger! If it is a one-shot sound, you should use audio.PlayOneShot() instead of audio.Play (which instead sets the sound to play continuously)
Otherwise, you will need to keep track of which objects are in your collider (with a list of gameObjects) and have one sound associated with each gameObject which stops when that gameObject leaves - hardly the most straightforward of solutions!