When you attach a bolt to something using a nut, it is clear what the roles of the nut and bold are. 



The more you tighten the bolt the more secure your fastening. However, you are often also told to use a washer as well.



I know this somehow prevents the bolt from loosening but from a physics/mathematics point of view, what is the role of the washer?


Some (smooth or Teflon) washers are used to reduce friction while tightening allowing for greater torque application and thus higher axial loads on the bolt.
Some washers increase the friction between the parts to prevent it from loosening up
Some split (or lock) washers act like a spring maintaining pressure in contact during thermal or elastic expansion and/or helps prevent unwinding of the nut by digging in the base material.
Some washers have a ratcheting surface to fix the nut in a particular orientation
Some washers are thick in order to re-distribute the contact pressure and soften the damage to the clamped body
Some washers are there to separate dissimilar metals to avoid galvanic corrosion
Some (belleville) washers reduce the stiffness of the connection in order to take up deformation better.


... the list goes on ...
