Ok, it works like this:
Damage (also called pDam to differentiate from magic damage (mDam)) is the raw physical damage on your weapon. It is the base amount of damage done by each white hit. It combines with weapon speed to derive DPS (Damage / Attack Speed = Base DPS). Base DPS is then factored by the %DPS value on your skills. This yields your Base Output. After you get that, Attack comes into play.
Attack (also called pAtk for same reason as seen above) is how much power you have to break the enemy's defense. It is calculated against the target's Defense (pDef) score to get a factor that modifies Base Output. If your pAtk is less than the target's pDef, your Base Output is reduced; you do less than full damage. On the other hand, if your pAtk is greater than the target's pDef, you do extra damage; though the ratio is different than the reduction for having pAtk<pDef. As a rule of thumb, if the pAtk:pDef ratio is 1:2, you're doing half your Base Output. On the other hand, if your pAtk:pDef ratio is 2:1, you will not do double your Base Output. According to formulas that people have worked out, you'd only be doing 1.5x Base Damage. The returns continue to diminish, capping at a factor of 2x when the ratio approaches infinity.
There is also a hidden damage factor on all skills equal to your pDam. To illustrate:
Say you have 100 damage, 2 attack speed, and a 150% DPS skill. Your DPS (100/2) is 50. The Base Output for these numbers is [(50 * 1.50) + 100]. The next thing to consider is the effect of pDam and pAtk food. You can only have one active at a time so there is much discussion as to which gives you the better benefit. The rule of thumb is that if your pAtk (without food) is already about 35-40% higher than the target's pDef, you'll get better benefit upping base damage through pDef food.
As a rule of thumb, for gear, you want to prioritize pDam over pAtk. You can get pAtk from many different pieces of equipment but pDam is only going to be available via your weapon. This is also why you want to prioritize tier of your weapon because getting it to a higher tier provides more pDam bonus (10% base pDam per tier over base tier), even if it means you put crap stats on it to save on Puris.
Got it?