There are two ways accents are used in Spanish.
To show unusual emphasis. When a word ends in a vowel, n or s, the emphasis falls on the second-to-last syllable, unless there is an accent on another syllable, which would show you where the emphasis falls, eg pájaro or información. Words ending in a consonant other than n or s have the stress on the last syllable, except when there is an accent, such as in árbol or the surname Márquez.
To differentiate between separate words. A written accent on a word does not always show an unusual emphasis; it could show two separate meanings. such as the question words cuándo and qué and their non-question counterparts cuando and que. There is no pronunciation difference, but the accents are still important because they clear up ambiguities in the written language.