It declares 2 variables. It doesn’t do anything else. So when you click on a song, 2 variables are created.
Now look at your loop,
songs.forEach((song) => {
const button = song.querySelector('button')
button.addEventListener("click", () => {
const idString = song.id.split('-')[1]
const id = Number(idString)
})
playSong(id) // <----- this runs in each iteration of the loop.
});
At the end of each loop you are calling a function to play the song.
So, in summary, you’re creating event listeners that do nothing but create variables that are used for nothing. And at the same time you are playing every song.