I usually see による used as a way to express the cause of something:
震災によってたくさんの人の命が失われた。
There were many people who lost their lives due to the earthquake.
But in some places I see it being used as a way to express dependency on something:
すべてはそれによるね
Everything depends on it.
How can I differentiate between those uses?