In many cases, they are interchangable. Let's say, John and Joe are talking in the street and we dont know them. We can say:
2 adam sokakta konuşuyor (more common) = 2 erkek sokakta konuşuyor = 2 men are talking in the street.
But these words also have some specific emphasises. For example, if you are filling in a form, when gender is asked, it is either "erkek" or "kadın". "Erkek" emphasises gender (and qualities related to that gender), whereas "adam" indicates qualities to be a "real man" or a nice person who deserves respect.
Now let's look at some examples, where they have different meanings:
** Sen gerçek bir erkeksin = You are truly a man (meaning that you show the qualities of male gender. you are brave, you are protecting your family etc)
** Sen iyi bir adamsın = You are a nice guy (man). (meaning that you show qualities of a nice person such as being caring, thoughtful, helpful. so i respect you and admire you)
** Sen büyüdün artık bir erkek oldun = You have grown up and now become a man (How can this sentence continue? "...so why are you still afraid of the dark" or "...you should have no fear" etc)
** Başbakan olmuşsun ama adam olamamışsın = You have become a prime minister but you couldnt become a man (you dont have necessary qualities to be a nice guy)
Now i will exagarate just to help you feel their meanings. The word "adam" raises respect. The word "erkek" raises fear or alarm. I repeat, I am exaggerating just to indicate the difference.