While you can record real instruments, these days there’s software available for music composition and production featuring virtual instruments. For instance, AudioSauna is a browser-based sequencer and Musescore is a free music notation program. Both are decent as free software. I started out using Musescore and converting to MIDI, which uses slightly better instrument samples.
If you’re serious about music production, you have to start talking money. I’ve used Cubase for several years now. I used it for every composition you can see on my channel. I started with a basic version and have gradually moved up to more advanced levels (each time I had to spend quite a lot, but what can you do). Cubase is an example of a DAW (Digital Audio Workstation) - you’re given a timeline, instrument slots and effect slots on those instruments and you load synthesized instruments, sampled instruments or recorded audio into the various channels, building up a track as you go.
This is a screenshot of the project file for the track above in Cubase. The horizontal bars correspond to instruments. The bottom left shows the mixer where you adjust track volumes and panning (how left or right a track is) while the bottom right shows the effects applied to the selected track. Things can get quite hectic with all the tracks and effects.
You can also use MIDI-based instruments such as keyboards to enter data. I have a small digital piano on my desk (and a larger one in the corner of the room) both connected to my PC, and when using Cubase I can record the notes played on these keyboards. You can then move them around, change the instrument and so on as you see fit.