By is a versatile preposition that can be used in many situations, but its versatility can make it confusing for English students. Here we explain its most common usages.
Perhaps the most common use of by is to identify the position of someone or something in relation to something else. In this context, by is static and can be used instead of beside or near, as a quick way to direct someone to something. Imagine that you are running late for work and trying to rush out the door but can't find your car keys. You shout up the stairs to your roommate, "Hey! Where are my keys?", and they shout back, "In the kitchen, by the kettle!" That piece of information tells you that they're neither in nor on the kettle - they are beside it.
That example does not mean that by can only be used for things in immediate proximity to something else. For example, if you lived in a house that was situated a short distance from a lake, you could accurately describe your house as being 'by the lake'. That is because in that context the lake is a notable and distinctive landmark close to your house, and so can be referred to in order to help someone identify its location.
By is not only used to express a position or location; it can also be used with a verb showing motion when you want to describe someone or something moving past a place. What you are moving past will still be beside you until you have passed it, so the idea of by being a position beside something else is still relevant. The addition of a verb of motion like run, walk, jog, etc. expresses the means of moving beyond it.
Here is an example of by being used in a sentence to show both movement and position: “The dog walked by the house (movement) that was by the lake (position).”
By can be used as a means of looking backwards to the origin of something and explaining where it comes from. In this context, it is a means of expressing who or what does, causes or creates something, and can be seen as the answer to a 'who' or 'what' question. For example:
Question: “Who wrote War and Peace?”
Answer: “It was written by Leo Tolstoy.”
Q: “Who did the washing up?”
A: “It was done by Paul.”
Q: “What made you so scared?”
A: “I was scared by the horror movie.”