As Bubbaman said it is a lot of knowing what masteries promote what playstyle and what playstyle your champion is.
For example if you are playing a tank it just makes sense to dip 18 points into resolve and you can always count on that being a good option, even if say for example an actual Taric player might know Windspeakers is better and would go 0-18-12.
If you are ever unsure know this:
ADC 18-12-0
Tank 0-12-18
Assassin/Burst Mage 12-18-0
Poke champ 18-12-0
Safe Shielding support 0-18-12
Attack Shield support 12-18-0
To break that down even more simply know this:
Am I poke or ADC? 18-12-0
Am I tank? 0-12-18
Am I burst or Karma? 12-18-0
Am I Janna? 0-18-12
Keystones tend to be pretty easy to pick, they tend to be pretty obvious except for the tank ones, but I will go through them all.
Warlords: If you are AD and want to play safe
Fervor: If you are AD and do sustained damage
DFT: If you are a poke/dot mage or Q-Varus
Stormraiders: If you are a melee who can get kited (Nasus)
Thunderlords: You are a burst mage/assassin
Windspeakers: You shield others
Grasp: You are a tank that trades a lot/tanky yasuo or Fiora
CotC: You are an engage tank
Bond: You are a tank support who doesn't want CotC, also good for health stacking tanks like Cho and Mundo
In the order of trees again:
Fervor vs Sorcery is Autoattacks(or jungler) vs ability damage. Jax likes Attack Speed. Illoi likes ability damage. Not AP, ability damage.
Do you wanna be safe? Feast. Support? Expose Weakness. Otherwise Fresh Blood.
Sustain vs Damage. Do you wanna stay healthier in lane or do more damage?
Bounty Hunter if you are confident, Battle Trance if you do dots or poke+DFG, otherwise double edged sword
Physical damage vs magic damage.
Support? Wanderer, otherwise Savagery.
Jg: Runic, Bot lane/safety secret stash, otherwise assassin.
Kill vs mana. If you are a push champ then go for mana regen. I prefer mana regen if you aren't familiar with your champ. Not as strong in ARAM.
Support get Bandit, otherwise get Dangerous game. Greenfathers is meh. I guess tank junglers can take it.
Damage vs CD's. If you are a burst mage/assassin go for damage. If you are Veigar, Nasus, or here for Windspeakers then go for the CDR.
Pretty much always grab the armour/MR unless you are mundo or cho
explorer for sup/jungler, siege if you expect to get pushed in, tough skin otherwise.
Runic if you heal/have healers, Veteran if you don't.
Insight for support/jungler, Perseverance mostly, Fearless if you trade frequently.
Swiftness. Just always get Swiftness.
It is a bit of a daunting list but a number of them are pretty obvious. So long as you are mostly going down the 2 correct trees and aren't grabbing mana regen on Riven you will be fine. If you do play ARAM a lot Bandit is really good if your champ doesn't have a ton of waveclear.
Figure out which ones give you the most trouble and learn those ones specifically. People might yell at me for some things in this guide. However by remembering these things I can always fill out my masteries to an acceptable level in the last 10 seconds of champ select and still have time to grab my skin. People who run through masteries fast aren't necessarily always grabbing the best ones, they are just sure to grab the important ones and the ones they favour. Example being my love for Vampirism. I would rather have my lifesteal/spellvamp on assassins than the extra damage because I play around safe kills that don't risk my life.