As someone else has already pointed out there was (almost certainly) a check box that was preset to install the unwanted application. Deselecting it would have eliminated the problem. That said, this is becoming a very widespread problem. You need to look carefully at each field before proceeding to the next stage of installation.
Currently the biggest problem is with browser hijackers and malevolent search engines ("ask", "jeeves" etc) and some of these can be extraordinarily hard to remove. In some cases a search for solutions can easily lead to additional malware installations, typically those that claim to discover hundreds of "infections" but which won't remove them until you install a paid upgrade. Even worse there are some instances where what appears to be a clean installation actually includes malware without any option to deselect it.
I recently got caught by one of these. I was looking to install "WinAmp", a well-established freeware audio application. As ever, Google threw up numerous different sites from which to download the WinAmp installer. I hastily selected one of the top returns and instantly had the feeling I'd been had. And I had been had. Now I'm no novice but the two vicious applications I'd installed almost defeated me. Mercifully I can't remember the names but one was a browser hijacker and the other a search engine.
I managed, with difficulty, to remove the first but the latter was incredibly tenacious. If you stopped the processes it was running in order to delete the executable and support files, they instantly restarted. Purging the registry likewise. It also disabled the System Restore process. In the end I had to do a complete system image re-installation - the first time I've had to do this on Win 8.1. In fact the whole process took me back to the sort of problems that were common on Win systems a decade or more ago.
When installing any of these freeware and shareware programs it's wise to think carefully about the source of the installers. Many of the program originators allow almost anyone to host their installers. Some of these sites are kosher and some are simply opportunities for predation. The well-established freeware aggregator sites (like FileHippo and MajorGeeks) are your best bet. If you can, determine the application creator's own website (which may require a bit of investigation first) and download only from there.
Think before you click!