I would like to know when should I use the prepositions By and away.
The meaning of preposition by is the same as beside or at the side of. It usually shows movement past a place.
The preposition away (from) is basically the same as from, but puts a stronger emphasis on leaving the starting point. It shows the place that someone / something left. To say this in another way, it shows the starting point of the movement (while to shows the destination or result).