Voluntary means done by choice, and usually without pay. Nobody made you, and nobody is paying you.
The two halves of that matter separately. Voluntary work is unpaid, which is what a volunteer does. A voluntary agreement is one entered into freely, and it is contrasted with a compulsory one. Medicine uses the word for muscles you can control at will, as opposed to involuntary ones like the heart. There is also a noun in church music, since a voluntary is an organ piece played before or after a service.
Voluntary is a matter of will. Latin voluntās meant will, choice or desire, from volō, to want, and it goes back to the same root as well: as one would have wished it.
Proto-Indo-European
*welh₁-
Middle English
voluntarie
English, today
voluntary
Built from
From Middle English voluntarie. From Middle English voluntarie, from Old French volontaire, from Latin voluntārius (“willing, of free will”), from voluntās (“will, choice, desire”), from volēns, present participle of volo (“to will”). Displaced native selfwille.
Etymology from Wiktionary, CC BY-SA