In English as it is used by native speakers, prepositions often appear before their objects, but they also appear in other parts of the sentence, depending on the situation. It may be easier to explain why this is the case if I start with an example that does not use a preposition. Consider the following sentences:
He is reading a magazine.
He is reading it.
In the second sentence, the word "magazine" was replaced by the pronoun "it." The word order remains the same in this type of situation, where we are simply rephrasing the sentence with a pronoun in place of its noun antecedent.
Now consider this sentence:
He is eating pasta.
If we convert this to a question using "what," it would be:
What is he eating?
The word "what" is an interrogative pronoun, and so it stands for another word. In this case, the word "what" stands for "pasta." However, unlike the first example with "magazine" and "it," when we are asking a question, we need to convert the word "pasta" to the pronoun "what" and also change the word order of the sentence by moving "what" to the beginning.
Now consider this sentence:
He is looking at artwork.
If we convert this to a question using "what," most English speakers would say this:
What is he looking at?
Just as with the "pasta" example, we convert "artwork" to the pronoun "what" and then move "what" to the beginning of the sentence. The only difference here is that the verb "look" requires the preposition "at" in this case. In English, the verb "to look at" is treated as a single unit in a way, and so we don't typically detach the word "at" in order to move it to the front of the sentence along with "what." The word "at" stays connected to "look." Even though "at" is a preposition which has the object "artwork," the connection between the verb "look" and the preposition "at" takes priority over the connection between "at" and "artwork."
Note: When I say it's "stronger," this is not a grammar term that is taught in school or anything like that. This is my way of saying that when words need to be moved around in a sentence (when asking a question, for example), then the words with a stronger connection will stay next to each other, and words with a weaker connection will be separated instead.
If all the words were people standing in a line holding hands, and we had to pull some of them apart in order to change the word order, then I would say that the word "at" is holding hands very strongly with "look," but "at" is holding hands weakly with "artwork." As a result, when we convert "artwork" to the pronoun "what," the pronoun "what" lets go of "at" when it moves to the front of the sentence.
In some other languages, such as Latin, French, and Spanish, the preposition would move to the front of the sentence along with the interrogative pronoun, and leaving the preposition at the end would sound strange to speakers of those languages. This was the logic that was used hundreds of years ago when some people thought that English should be more like Latin. Since prepositions need to appear before the object of the preposition in Latin, even when asking questions, these misguided scholars tried to force this rule onto the English language. However, English functions differently than Latin. English is a Germanic language with a different historical development than Latin and the Romance languages (French, Spanish, etc.). In English, if you tried saying, "At what are you looking?" it would sound awkward to most people's ears. In contrast, it sounds very natural to ask, "What are you looking at?"
Part of the reason it sounds so awkward to move "at" to the beginning of the sentence is that "to look at" acts as if it's a single unit, as I mentioned above. In English, when a verb plus another word (usually a preposition) act together to create a meaning that is different than the verb by itself, they are called phrasal verbs.
Two examples of phrasal verbs are "to hit on" and "to give up." "To hit on" someone means to flirt with someone and compliment that person; it does not mean to "hit" them. If someone "gives up" smoking, it means they have quit the habit of smoking; they are not "giving" something to anybody and nothing is moving "up." From these examples, we can see that the phrasal verb's meaning can be completely different from the meaning of the individual words that make up the phrasal verb. As a result of this, the words in these verbs usually stay close together in a sentence so that their meaning stays intact.
Consider this sentence:
Joe is hitting on that student.
If we know Joe but don't know the student, we might ask this question:
Who is Joe hitting on?
Note: This is an example of informal speech. Some people would prefer to use "Whom" instead of "Who," which would be following formal and academic rules for English. For a casual conversation, "Who" seems much more natural to me for this example sentence. See my note at the bottom regarding "who" versus "whom" for more information on this.
The words "that student" were converted to "who" and then "who" moved to the front of the sentence. Even though someone might say that "on that student" is a prepositional phrase, the word "on" is not acting as an independent preposition because it's part of the verb "hitting on." Therefore, it sounds best to keep the phrasal verb together and only to move the word "who." If we moved the word "on" to the front of the sentence along with "who," the result would sound unnatural to native speakers.
There are situations that do not involve phrasal verbs, but just verbs that can have prepositions following them. In these cases, the preposition often remains at the end of the sentence or the end of the phrase in casual speech, but it can move in formal versions of the language.
Example:
We moved to a town.
If we want to say something about this town (it's nice!) and also mention that we moved to the town, the sentence would sound like this:
The town that we moved to is nice! (casual speech)
In this example, it sounds completely natural in casual speech to use this word order. You can think of "moved to" as a single unit, so the word "to" does not move away from "moved." However, in a formal context, there is a way to re-phrase this sentence that sounds formal but is "correct" English:
The town to which we moved is nice!
In this version, the word "to" is separated from "move" and is placed before the pronoun "which" in order to create the dependent clause "to which we moved." If this is confusing, consider the following three examples: "I read a book." and "The book was interesting." and "The book that I read was interesting." In order to combine the ideas from the first two sentences and create the third sentence, the word "that" is used to add a description about the book: it's a book "that I read." We could also combine the first two in a different way: "I read a book that was interesting." This is also correct, and it also uses "that" to add a description about the book: it was a book "that was interesting." When there is a pronoun after the verb, as in "move to," and if we want move the preposition to the front because we wish to sound formal, we cannot use the word "that" anymore. It is wrong to try to say, "The town to that we moved is nice!" This sounds wrong to a native speaker's ear because we must use "which" after a preposition in this case: "The town to which we moved is nice!" is formally correct.
One more thing about phrasal verbs: There is one notable exception to the "rule" that the words that make up phrasal verbs like to stay close together. When the phrasal verb has an object, and especially if the object is a pronoun (instead of a noun), the object often appears inside the phrasal verb instead of after it!
Examples:
Non-phrasal verb with a typical subject-verb-object word order:
I wrote that novel. --> I wrote it.
Phrasal verbs: Word order often places the object of the verb (especially if it's a pronoun) between the two words of the phrasal verb:
To give up: to stop a bad habit
I gave up smoking years ago. --> I gave it up years ago.
To curse out: to yell at someone angrily
She cursed out that man. --> She cursed him out.
To pick up: to drive somewhere to give someone a ride in your car
I picked up my sister from soccer practice. --> I picked her up from soccer practice.
It would also sound correct to use this type of word order certain cases even when a noun and not a pronoun is not used. For example, "I gave smoking up years ago" and "I picked my sister up from soccer practice" both sound alright to me. However, it does NOT sound correct to place a pronoun after the phrasal verb most of the time. For example, it sounds incorrect to say, "I gave up it years ago" or "I picked up her from soccer practice" -- both of those would sound strange. The pronoun needs to go between the two words in the phrasal verb in those cases.
All of this discussion of formal versus casual speech and what is "correct" or "incorrect" brings to mind an issue that any student of linguistics should seriously think about. (Or, to be more formal, it brings to mind an issue about which any student of linguistics should seriously think -- but that sounds a little TOO formal and awkward, in my opinion...)
The issue that you should think about is: Who makes the rules for a language, and why should we listen to that person instead of others? The answer to this question from the prescriptivist perspective has never been satisfactory to me and seems always to be either arbitrary or motivated by some kind of prejudice. Academic linguistics is the rigorous, scientific study of language. Any study that is "scientific" is based first and foremost on OBSERVATION of what naturally occurs. Thus, if native speakers consistently say X, then X is a part of their language. This is what is meant by a descriptivist perspective in linguistics -- we describe what we observe among speakers of the language and we try to discover consistent patterns for how native speakers use the language. We might refer to the patterns that we observe as "rules," but a descriptivist linguist is merely "describing" what he or she observes to be in usage.
To make an analogy: Linguists who are studying people's use of language are similar to biologists who are studying an animal's mating behaviors, because they are both conducting scientific studies of naturally occurring phenomena. If a biologist observed a bird doing a variation of a mating ritual that had not been described before in that species, would it be reasonable for the biologist to say that this bird was doing the "wrong" mating ritual? Should the biologist claim that the bird should learn the "correct" ritual that had previously been described in textbooks? No, that would be ridiculous.
It would make sense for the biologist to note that there is variation in the mating ritual in this bird species -- and further study could perhaps discover that there are different circumstances leading to the use of one ritual versus another in this bird species; or perhaps this species of bird has begun to use different versions of mating rituals in different regions as part of natural evolutionary processes. It's possible that previous biologists had failed to realize how complex the bird's behaviors were, and therefore those biologists had not included details about the full extent of this bird's mating behavior in textbooks. In this case, where the bird's behavior does not match the information about the bird that is written in a book, the bird is not wrong; the textbook is wrong for failing to describe what occurs naturally. If those mating behaviors are occurring in nature, then they cannot be "incorrect" -- it's hard to imagine how that would make any sense. Our human understanding of these behaviors may be incorrect at times and we can correct those misunderstandings through additional study and observation.
Similarly, in a language like English, there are speakers in different regions and from different social groups, and they are using the language in different settings throughout their daily lives, and all of these variations lead to variations in the language -- different dialects, different registers, different degrees of formality, new words, slang words, and so on. One way of saying something is not inherently superior to another way of expressing the same idea, but if people have prejudices against certain groups of people, or if they have irrational biases based on what they are accustomed to hearing or what they heard when they were young, then they may decide that one variation is better than another. Certain accents may be labeled as "low-class" or "stupid" or "sophisticated" or "snobby," but these are all opinions that we have attached to the use of the language. Saying, "He ain't here" is usually considered lower-class than saying, "He isn't here," but there is no scientific reason why one form functions better than another. Claiming that one dialect of the language is superior to another dialect, even though they both effectively communicate information, would be like saying that one bird's mating ritual is superior to another bird's mating ritual, even if both rituals are used successfully during mating in this bird species. All languages being used by living, breathing people are constantly changing, and change means that there is variety. This is an unavoidable part of how human languages work, and it's why we have different languages around the world. It's why Latin has changed over time to become French, Spanish, Italian, and other modern tongues. It's why modern English sounds completely different from the English of 1000 years ago, and why 1000 years from now, English will have changed in countless new ways (if we human beings are still around to speak it).
Note on Who versus Whom: In the sentence "Who is Joe hitting on?" the choice of whether to use "who" or "whom" depends largely on how formal the context is. In modern English, many people use "who" for both the subjective and objective case, especially in casual speech. In formal settings, "who" is used for the subjective case and "whom" is usually used for the objective case (especially in writing), but many native speakers don't even know the formal rules for when to use "whom" or "who" because in natural speech, "who" has taken on the functions of both "who" and "whom" for the most part. Some people make the mistake of thinking that "who" is always more casual and "whom" is always more formal. However, even using traditional rules of English grammar, sometimes "who" is the proper choice and sometimes "whom" is correct -- therefore, the word "whom" may indicate a formal context since it typically doesn't appear in casual speech, but the presence of the word "who" does not necessarily indicate an informal context. Occasionally, someone who is trying to sound intelligent or sophisticated will use "whom" in place of "who" even when "who" is the proper choice because they see or hear "whom" in formal settings and so they think it is the formal equivalent of "who" in all cases. Avoid making that mistake! Here's a trick you can use if you are not sure whether "who" or "whom" is appropriate and you are writing in a formal context: If the sentence is a question, the answer will be "he" if the pronoun was "who," and the answer will be "him" if the pronoun was "whom." If it's not a question, try re-stating the sentence with "he" or "him" in place of "who(m)" and see which one sounds right.
For example, "Who/Whom did you see?" The answer would be, "I saw him" (NOT "I saw he"). Therefore, the pronoun would be "whom" --> "Whom did you see?"
Another example: "They will announce who/whom won the race." To re-phrase this we could say, "They will announce that he won the race" (NOT "him won the race), so the pronoun would be "who" --> "They will announce who won the race." Remember, the issue of using "who" or "whom" his is for formal settings; in casual speech, always using "who" is fine.