A preposition is a word used to show a relationship between a noun or pronoun and the rest of the sentence. Prepositions may indicate relationships such as time, movement, or location. A preposition usually begins a prepositional phrase which may function grammatically as an adjective or an adverb.
Jack is the man with the dark hair.
The preposition with starts the prepositional phrase with the dark hair. The noun hair is the object of the preposition. The entire prepositional phrase is functioning as an adjective describing the noun man.
Sarah and Becky walked to class this morning.
The preposition to starts the prepositional phrase to class. This phrase functions as an adverb modifying the verb walked to tell where Sarah and Becky walked.
Since there are so many prepositions that can do so many different things, the best way to recognize them is to simply be familiar with a good list of common prepositions.