I don't even know where to start here...
The truth is, it is not inaccurate to say "do what the mix tells you (i.e. what the mix needs)" in response to a question of how to master.
...and the fact is, the same thing goes for mixing and songwriting (each of which are all very specific craft and art, no less so than mastering.)
Mastering, mixing, and songwriting ALL take a lifetime to learn. That is a fact. Every day that goes by, you will get better and better... and if you actually have a talent for it, you may become great.
It should be a given that you need the highest quality equipment... and that goes for mixing, recording and mastering EQUALLY.
...you shouldn't need someone to tell you that... even though it has been told to you countless times.
in order to master (or mix or record) you will need a complete intimate understanding of various tools such as compressors and EQ's...
...not to mention (with regard to mastering) the guidelines for preparing a finished master ready for manufacture, which is really the ultimate goal of having a record mastered... but I have a feeling that when people ask how to "master" they are really asking "how do I make my track sound as loud as that song from that CD and how do I master it so the mix sounds like a professional CD" (and in that case, there are a lot more steps you need to address before you reach your goals.)
You will need to have the ability to objectively look at a piece of music and hear and understand what needs to be done to it.
(i.e., doing what the music is telling you to do)
You can give instruction on the technicalities of how to use various pieces of equipment and what the various controls do and you can explain what types of sounds have fast attacks (or whatever), but actually using it in the proper place in the proper way is up to the users ability to:
1. hear what the audio needs;
2. decide which tool is the proper one to use; and
3. use it effectively
Some people seem to just be happy having someone tell them what to do whether it is correct and useful information or not.
Someone could tell you some completely useless and false information and people will say "finally! thanks for the help man! good lookin out!"
Please understand this:
There is no "frequency" someone can tell you to boost.
There is no "compressor setting" someone can give you.
There is no "level" someone can tell you to make an instrument in a mix.
--these are all things the audio will "tell" you it needs... and it is up to you to be able to hear what the audio is saying and it is up to you to know how to "answer it when it speaks."
If you are mastering your own material, there should be NO CORRECTIVE MEASURES NEEDED with mastering.
If your hi-hat is too loud, you don't need to try to correct it in mastering... you just lower the hi-hat in your mix!
If your mix doesn't sound right and basically like what it should sound like on the album, then you didn't mix it well.
With regard to both mixing and/or mastering (not everything I am going to mention will apply to both), you can be told things like "don't overcompress, get your levels sounding good, pan your instruments in a balanced way, make sure each instrument has its own space, make the overall album sound consistent, etc"
...but it is up to you to know your tools and how to use them... and it is up to you to know what sounds right.
Every day, I see several people here saying "you should pan this here and use this compresor setting and boost this frequency and roll this off and copy this to another track and use this plugin and this preset and this synth"
...and it is generally bad advice...
...and people say "thanks for the great tips!" because they don't know any better.
If you want to get some help on your mixing, maybe try posting one of your mixes and ask people to critique it. Maybe you can get an objective opinion on whether you need to raise the level of your snare... or if you have too much reverb on your vocal... or if some effect you used sounds cheesy... or if your stereo spread is off... or if the strings sound dull... or you have too much compression on the guitar... or you need to automate the level of the solo section... or whatever
If you want help with your mastering... post something you mastered and have people critique it. Maybe you can get an objective opinion on it. Maybe someone can tell you "it sounds like you have a lot of compression on the track, which is not my taste, but if that is your artistic decision then it is good... but it sounds like you have the release set too long because I can hear the compressor recovering" or whatever.
...and that should do it...
...you are now on your way to becoming a great recording/mixing/mastering engineer!