that's how harmony works. there are plenty ways of arranging chords, but not unlimited. that's where polyphony and atonal combinations find their way into the song and here is the difference between a song and a good song.

and of course there are so much more things than chords for accompaniment. it's actually not hard to write such a prog. all you need is some samples, an engine which can render them into different pitches and a fast fourier transformation for the melody to gather the most probable chords which fit to the voice.