1. Used to indicate proximity. Example :
Can I sit by you?
The post office is by the bank.
2. Used to indicate the person that does something in a passive voice sentence. Example :
The microwave was fixed by the mechanic.
The flowers were delivered by a postman.
3. Used to indicate an action with a particular purpose. Example :
You can pass the exam by preparing for it.
She finally broke the record by pure effort.
4. Used to indicate a mean or method. Example :
Please send this package to Russia by airmail.
I came here by subway.