To retain something is to keep it, keep possession of.
To remain is to stay in place, continue to exist.
So you could have:
I retained my place in the queue.
I remained in my place in the queue.
Both sentences show that you are in the same place in the queue, but one is implying "possession" of the space, while the other shows only occupation of the space.
Basically to use them correctly only use retain in the sense of possession. You can normally swap the word retain with keep and the sentence will have the same meaning.