Mixing is the process of balancing each separate instrument with each other, bringing clarity, width, life and expression to the sound. Mastering is the process of balancing the overall mix, controlling dynamics, maximizing loudness, and formatting the audio to the most acceptable standards of today's channels of music consumption (mostly streaming protocols). Each are separate disciplines with some crossover in the area of balancing and dynamic control.
An analogy of mixing and mastering would be this. Imagine you're cooking a meal. That meal takes ingredients needing certain amounts mixed together in order to blend correctly. That's like audio mixing. Then the food is actually cooked.. put in the oven, or sizzled on the stove top...lightly seasoning to taste as you go. This is mastering.
You need both mixing and mastering, just like we all need our food cooked (for the most part.. salads don't count, but then again, the dressing is like the mastering). Mastering is the key ingredient to get those streaming algorithms to include your songs in their playlists alongside commercial mainstream hits. But you can't leave out the mixing stage... otherwise you severally limit the potential of how amazing Mastering can make it sound. Badly mixed ingredients will still taste bad no matter how you cook it!
Here's all of the info on mixing and mastering here - https://sfrbeats.com/mixing-mastering - I hope that analogy helped! :D