This confuse me yet
You can use "for" to do something or to someone or also you use it in order to do sequential things.
Example: Would you do that for me? Another example: Can you close the window for me please? Ex: "I do it for you" Ex: "You will need to be there in time for your driving test" Ex: "Subscribe for more videos" Ex: "She works for living"
You use "by" when it's related to something made by someone or used by.
Example: When you see the credits of some film you can see "Music by: *" it means the soundtrack of the film was selected by that person. Another example: "by my side" it means you're really close to someone. Another one... Ex: "I go to school by car" it means the person is driven to school, the person uses a car to go to school. Another ex: "The letter was written by me". It means the person wrote the letter.
I hope this helps.
We are using "For" when we are talking about the activity, which is happening with reference to somebody or something. Example -"It was a shock for me when I realized, that the people I thought were saints are criminals." " By" we are using when we are talking about activity, which coming into being is caused by someone or something. Example-There are circles, in which many girls aren't getting married since their life is controlled by the organization dealing with the degradation of human life.