Adam (AS) is a prophet and every prophet is infallible. Adam (AS) did not commit any sin at all. He was not given an obligatory order to avoid that tree but was just been advised as a good advise to follow. It was the best for Adam (AS) to avoid that tree but it was never an order to him to do so. We need to distinguish between the order and the advice.
Translations of Quranic meanings are not accurate and some translations are misguiding by translating the advice as an order.
'Shaitan swore by Allah to Adam and Eve that: I am a well wishes, sincerely advising you (Sura 7, verse 21)
Adam (AS) never thought that any one can swear wrongly by the name of Allah.
He thought that it was a sincere advice, and he did not go against any obligatory order from Allah (SWT).