This is a very big question. I am a fan. Let me share my personal experience for reference only.
In fact, composing music is not a particularly difficult thing for professionals. Professionals and people with musical skills can actually compose music with a piece of paper and a pen. There is no need for anything special. The same is true for given words and music. Gao Xiaosong wrote the theme song for "Da Wu Sheng" in prison with just a piece of paper and a pen. But not everyone is that good. Amateurs and those with lower levels can use auxiliary instruments, such as guitars and pianos, to find what they are good at.
After the main melody is decided, it is time to arrange the music. Which instruments are needed and what the melody of each instrument is like is written first.
Then there is recording and production, including musical instrument recording and vocal recording. When it comes to midi production, you need to use a computer to adjust the tone and make related audio tracks. In real production, each instrument is an independent audio track. It is recorded and produced individually, unlike live performances where everyone performs together.
Then there is post-production, the sounds of musical instruments and human voices all need to be processed.
Finally, it is mixed into the finished product.
It is relatively simple, but many places also require a lot of detailed support.
Hope it can be useful to you~~