Start With a Goal in Mind
Optimization in Pathfinder can be class-based, but more often it's goal-based; you want to create a powerful archer, or control the battlefield, or have the smoothest talker to ever talk smoothly. Start with a mechanical goal, since we're talking mechanics, and that'll give you something to focus around for your initial explorations into optimization.
Do Some Research
That statement is deceptively simple; though it has less options than 3.5 did, Pathfinder is still a very large and ever-expanding system with tons of available content. What I've found to be a good practice is to do some initial digging with the PFSRD and/or your own books and then post the concept and build up online, where others can help you with it. Don't brag when you do it - say that you have X goal ("I want to control the battlefield") and this is what you came up with so far.
When you're picking up your options, ask yourself a few questions - how much is this option costing me? Can I get that resource back if I don't like it? If I can get it a different way, what're the relative costs of the two options? For example, cash is cheaper than feats so it's usually better to get something with money rather than spending a feat slot because you can't normally get that feat slot back - whereas you can always sell an item later. Learning a spell is cheap, but taking an entire level is "expensive". This is probably the hardest part of learning optimization - being able to think in terms of fulfilling a goal efficiently. The more resources you have to invest in something, the more things you aren't getting for those resources.
Whenever possible, take options that you can apply to more situations than just your goal. A great example of this are metamagic feats - if you're out to optimize, say, the enervate spell, then Empower Spell is a great feat. You can also use it for things that aren't enervate! The more situations you can apply an option to, the more chances for narrative power - the power to shape the campaign setting as you wish it to be - you have.
Think About Your Meta
What's optimal in a kick-in-the-door game with little-to-no-roleplaying is not necessarily what's optimal in a game centered around political intrigue. Most optimization discussions you'll find online are geared towards a 'general spread' kind of game where you'll experience combat, traps, puzzles, and social challenges all in the same game. If that's not the case in your game, the value of options shifts to reflect whatever is emphasized or missing. For example, in a game with lots of combats sustainability might be the name of the game when it comes to optimizing combat options, but in a sandbox game you might want to talk instead about optimizing threat-assessment, defensive options, and social skills.
Ask How Many Ways You Can Do This
One thing that helps you scale optimization to power levels is comparing many ways of doing the same thing. For example, say you want to have a given spell to hand whenever you need it as a Sorcerer. You could use contingency to make sure it's always up, which requires three resources - two spells known and your active contingency. You could buy it as one or several scrolls or wands, which eats up money. Or you could play a half-elf and use paragon surge to instantly learn the spell whenever you feel like you need it, which costs one spell known and gives you, literally, infinite effective spells known on demand. Then when you look at the power level of the campaign, you can decide which option - and its resource costs - is appropriate for you. Asking how many different ways you can do a particular task is also a great way to focus when you're diving through the piles and piles of options available to you, and a great way to look at direct cost-comparison since you have one end goal in mind which is then compared against the costs of the various options.
Diamonds Are Forever
The thing that makes the powerful classes in Pathfinder as powerful as they are is how casually they can recover from build mistakes and shift their focus to handle a new day's worth of adventuring. Wizards, clerics, druids - it's helpful to think of their spells as class features that they get to change every single day. To contrast, characters like fighters, rogues, and barbarians don't get to change their class features ever. Options you can change, or which increase or possess versatility, are always going to be mechanically superior to those that do not.
Some General Advice
Feats and Class Levels are generally the highest prices you can pay for a given option, especially if it involves giving up caster levels on a character focused around spellcasting. You can never get these valuable options back unless the DM is using retraining rules, and even then there's a cost to your 'refund' which you won't be seeing back again.
Money is almost always the cheapest cost to pay for any capability.
Prepared spellcasters can re-optimize their builds every morning just by memorizing new spells. Consider taking Cleric or Druid for a test drive to see how spell selection alone can affect a character's power levels.
Study the monsters in the PFSRD at various challenge ratings. When do special capabilities like flight become common? How about spellcasting? Pouncing? Incorporeality? Summons? Immunities? Ask yourself how you can prepare for encounters you can't predict, then ask yourself how you can predict them anyway and then prepare.
He who fights and runs away lives to fight another day.