This is a very wide range of tools. Music can be represented and created in various forms. An established and widespread method is the presentation and processing of music in the form of individual events, organized in tracks and chronological sections. Famous commercial "computer aided design" tools for this approach are, for example, Logic Pro from Apple or Cubase from Steinberg. There are many open source alternatives; a useful list is e.g. here: https://alternativeto.net/software/logic-pro/?license=openso...
But music can also be represented and composed in the form of program code, usind a special programming language, for example. Here is a good overview of available (open source) solutions: https://en.wikipedia.org/wiki/List_of_audio_programming_lang...
Garage Band is free for iPhones, iPads, and Macs.
Maybe you already have an iPhone. Maybe you don't. But you have to buy hardware irrespective of what software you use.
Good luck.