There's sort of two answers here:
1 is "mastering". part of the mastering process is usually adding compression/limiting to get the overall volume of the project to the optimal level for the media it's being released in.
2 is "you don't". From the early 2000s through the late 2010s, the recording industry had what was called the "loudness war". Basically, people noticed that all other things being equal, a louder recording sounds better to listeners than a slightly quieter one. This set off a race to see who could compress and limit their recordings the most, resulting in a lot of recordings with very little dynamic range. Everything was as loud as possible, even the parts that should have been quiet.
But, in the last few years, every streaming service has added their own volume normalization algorithm, which means that mixes that are too compressed just get turned down when they're streamed, and mixes that are too quiet get turned up. So it doesn't really matter how loud your mix actually is; the streaming sites will match it to the professional level.
So tl;dr, do some research in mastering to figure out how to adjust these levels, but you probably don't want to target major label releases because that will result in you over-compressing