A preposition is a word in the sentence that often shows the relation between a Noun or a Pronoun (which is its object) and another word, phrase or clause in the sentence. But more important is a Preposition's function in the sentence in forming phrases of different kinds namely Adjective Phrase, Adverb Phrase and Verb Phrase or Phrasal Verb.
(A) Adjective Phrase
A preposition along with a Noun as its object can form an Adjective Phrase.
Look at the following sentences:
a. Mr. Sharma is a man of principle.
b. A man in troubles should maintain a level head.
In these sentences, 'of' and 'in' along with its object (noun) 'principle' and 'troubles' is forming an Adjective Phrase 'of principle' and 'in troubles' respectively. The phrases 'of principle' and 'in troubles' are qualifying the noun, 'man' in both the sentences and are therefore, functioning as Adjective.
(B) Adverb Phrase
A preposition with a Noun as its object can form an Adverb Phrase.
Look at the following sentences:
a. We went to the market.
b. The plane landed early in the morning.
In these sentences, the prepositions 'to' and 'in' are forming a phrase along with their objects (nouns) 'the market' and 'the morning' respectively. These phrases 'to the market' and 'in the morning', modifying the verbs 'went' and 'landed', tell about the place and time of action respectively and are, therefore, functioning as Adverb.
Also See: Prepostion of Verb and Adverb