A preposition is a word used to establish relationships between nouns, between nouns and verbs, and between different parts of a sentence. Prepositions usually have spatial or temporal meanings (e.g. beneath, between, in front of, before, after, during, etc). Prepositions are invariable, that is, they have one form with the exception of a and de which contract with the definite article el.
Translating prepositions is notoriously tricky. Never assume that Spanish will use the same preposition as English to express a particular meaning. In fact, there are many cases where one language requires a preposition where the other does not. In general, it is best to treat prepositions as vocabulary items requiring memorization.