You're correct, syncing music is one way, from iTunes to the device. There is no native method for moving non-iTunes Store music on a device, into iTunes. But as you have read, there are solutions, that cost money (if you have more than a few songs). Check out this user tip from user tt2; Recover your iTunes library from your iPo… - Apple Community who has listed (in that tip) the various software solutions that you might consider.
The only other method is to use the original source. So if the music was from:
- CDs, use the CD to import the music into your iTunes Library
- online purchases (such as Amazon, Bandcamp, etc.), go to your account with that outlet and re-download the songs again. (Not all retailers offer this option, I don't know why)
In order to avoid this situation again, may I suggest that once you have all your music in your iTunes Library, you make a backup of all your music? Be sure to include purchases from the iTunes Store as well. Once you have all your music on your computer, use Windows Explorer to copy the music (which should all end up in the Music folder) to an external drive. At the very least, use another drive inside your computer.
iPhones, iPads etc. are not backups; what is on your computer is the backup of what is on your portable devices. Those devices can get lost, stolen, broken, or in the end, simply fail. Drives in your computer can fail too. Therefore, the best practice is to back everything up to an external drive.
The reason you perform the backup in Windows Explorer is because iTunes does not have (and has never had) a facility to backup your music.