Accentuation in Spanish is used to guide the reader into how a word is pronounced. The idea is that a word can be chopped into syllables, and the syllable with the accent in it will be the strongest one, or "tónica". If you know the rules to accentuation properly, then you will also know which syllable is the strong one in words without accents.
There are three types of words according to where the strong syllable is placed:
Acute words (palabras agudas): the strongest syllable is the last one in the word. They are accentuated if and only they end in a vowel (-a, -e, -i, -o, -u), a vowel+s (-as, -es, -is, -os, -us), or a vowel+n (-an, -en, -in, -on, -un). Examples would be "camión" (van) and "color" (colour).
Flat words (palabras llanas): the strongest syllable is the second to last one in the word - these are the most common. They are accentuated in the opposite scenario of acute words, so when they don't end in a vowel, vowel+s, or vowel+n. Examples would be "lápiz" (pencil) and "casa" (house).
"Esdrújula" words (palabras esdrújulas): the last syllable but two is the strongest one. By definition only words with at least three syllables can be esdrújulas, and they are always accentuated. Examples would be "brújula" (compass) and "rúcula" (rocket - salad).