A preposition describes a relationship between other words in a sentence. In itself, a word like "in" or "after" is rather meaningless and hard to define in mere words. For instance, when you do try to define a preposition like "in" or "between" or "on," you invariably use your hands to show how something is situated in relationship to something else. Prepositions are nearly always combined with other words in structures called prepositional phrases. Prepositional phrases can be made up of a million different words, but they tend to be built the same: a preposition followed by a determiner and an adjective or two, followed by a pronoun or noun (called the object of the preposition). This whole phrase, in turn, takes on a modifying role, acting as an adjective or an adverb, locating something in time and space, modifying a noun, or telling when or where or under what conditions something happened.
Consider the professor's desk and all the prepositional phrases we can use while talking about it.
You can sit before the desk (or in front of the desk). The professor can sit on the desk (when he's being informal) or behind the desk, and then his feet are under the desk or beneath the desk. He can stand beside the desk (meaning next to the desk), before the desk, between the desk and you, or even on the desk (if he's really strange). If he's clumsy, he can bump into the desk or try to walk through the desk (and stuff would fall off the desk). Passing his hands over the desk or resting his elbows upon the desk, he often looks across the desk and speaks of the desk or concerning the desk as if there were nothing else like the desk. Because he thinks of nothing except the desk, sometimes you wonder about the desk, what's in the desk, what he paid for the desk, and if he could live without the desk. You can walk toward the desk, to the desk, around the desk, by the desk, and even past the desk while he sits at the desk or leans against the desk.
All of this happens, of course, in time: during the class, before the class, until the class, throughout the class, after the class, etc. And the professor can sit there in a bad mood [another adverbial construction].
Those words in bold blue font are all prepositions. Some prepositions do other things besides locate in space or time — "My brother is like my father." "Everyone in the class except me got the answer." — but nearly all of them modify in one way or another. It is possible for a preposition phrase to act as a noun — "During a church service is not a good time to discuss picnic plans" or "In the South Pacific is where I long to be" — but this is seldom appropriate in formal or academic writing.