These function as adjectives or adverbs.
There are two prepositional phrases in the example below.
The cake with nuts fell onto the floor.
With nuts is a prepositional phrase that is acting as an adjective. You can tell that it's an adjective because the word with is branching off of the noun cake. (You remember that adjectives modify nouns and pronouns, right?)
Onto the floor is a prepositional phrase that is acting as an adverb. You can tell that it's an adverb because the word onto is branching off of the verb fell. (You remember that adverbs modify verbs, adjectives, or other adverbs, right?)
Are you wondering how to diagram prepositional phrases? I thought so. I have a knack for reading people's minds. Click on that link to learn more.
Learn more about prepositional phrases here.