Using the same cake analogy as above: if your song is a cake, then mixing is how you combine the ingredients to bake the cake. Mastering is the icing on top that glues it all together. Even if you have the best ingredients in the world, but the baker isn’t very skilled, then the cake still won’t come out its best.
Technically speaking, mixing is the combination of all the musical and vocal tracks of a song. It is the process of balancing the tracks so that each one sits properly in the mix and sounds pleasant to the ear. A good mix can greatly impact the perceived “goodness” of a song.
Mastering is the final step in completing a song. It is the glue that holds the whole song together. It is the process of balancing the elements of a song and optimizing playback across all systems and media formats. The main purpose is to make the song louder while also retaining its dynamics and not leaving it sounding “squashed.”
If you are serious about your music, hiring someone to properly mix and master your song is key. A good mix will bring your song from decent to utterly amazing, and a good master will optimize your song for playback on all platforms.