When guides say "build x against AP and y against AD", they don't mean AP or AD. They mean magic damage and physical damage; it's just easier to write AD and AP, and for most older champions building AD leads to them dealing mostly physical damage while building AP leads to them dealing mostly magic damage (Sion and Master Yi are two prime examples).
These days, though, looking at a champions items or stats doesn't always help you when deciding whether to build more armor or magic resist. For example, Darius' passive, Hemorrage, deals magic damage but scales with bonus AD. Poppy's Devastating Blow scales is an "on next attack" modifier that scales with total AD but converts all damage dealt (including damage dealt by your basic attack) to magic damage. Building only armor against Darius or Poppy isn't a very good idea, even if they both build a lot of AD items. Jax (Leap Strike) and Akali (Crescent Slash) are two examples of champions with abilities that scale off of AP but deal physical damage.
The only way to know for sure what damage type an enemy primarily deals is to look them up ahead of time, then compare the scaling on their abilities to what they are building. That said, almost no abilities scale with AP but deal physical damage (Akali's Crescent strike is a notable example of an AP scaling ability that deals physical damage), so if the enemy builds AP chances are they're going to be magic damage based.