Which "For" to use?

If ‘Am’ means for, and ‘Ar gyfer’ means for, are they interchangeable or is each one used for a specific purpose?

Thanks in anticipation for any replies.

Generally speaking, prepositions are almost impossible to map one-on-one, so the best approach is to learn the context, as you say. am can mean “for”, but it has other uses as well.
An example for am:
I’m looking for something - Dwi’n chwilio am rywbeth.
And an example for ar gyfer:
Here is a present for your Mum - Dyma anrheg ar gyfer dy fam.