Зачем and Почему – both these words the google translator will translate as “why”. Yes, they both can mean “why” but there is a small difference.

Почему? – why? – this word always means “why”.

Зачем? – why? Meaning of this word is closer to “for what/what for?”

Почему ты учишься на программиста? – Why do you study to be a programmer?

Зачем ты учишься на программиста? – Why/What for do you study to be a programmer?

There is also Для чего? – for what? That has the same meaning as Зачем.

Also, here are the roots of the word Зачем: this word consists of two words за чем that also means “what for?”!