"почему" is the question of reason:
- Почему ты купил лекарство?(WHY did you buy medicine?)
- Потому что моя мама больна.(Because my mom is sick.)
"зачем" is the question of goal:
- Зачем ты купил лекарство?(FOR WHAT did you buy medicine?)
- За тем, чтобы моя мама выздоровела.(For my mom gets recovered after sickness)