Can a binary operation have an identity element when it is not associative and commutative?
Asserting that the operation $*$ is not commutative means that there are elements $a$ and $b$ such that $a*b\neq b*a$. It does not mean that $a*b\neq b*a$ for any two distinct elements $a$ and $b$. Therefore, an operation may well not be commutative and, even so, to have an identity element. There is no contradiction here.
For an example of a non-commutative and non-associative algebraic structure with an identity element, take, for instance, the octonions.
An operation is commutative if for any $a$ and $b$, we have $ab=ba$. Finding one pair $a,b$ such that $ab=ba$ doesn't prove the operation is commutative; this has to hold for every pair.
Consider the set $\{a,b,c\}$ whose binary operation $\cdot$ is given by the following: $$a\cdot a = a\,\,\,\,\,\,\,\,\,\,\, a\cdot b=b\,\,\,\,\,\,\,\,\,\,\,a\cdot c=c$$ $$b\cdot a = b\,\,\,\,\,\,\,\,\,\,\, b\cdot b=b\,\,\,\,\,\,\,\,\,\,\,b\cdot c=c$$ $$c\cdot a = c\,\,\,\,\,\,\,\,\,\,\, c\cdot b=b\,\,\,\,\,\,\,\,\,\,\,c\cdot c=a$$ This operation has $a$ as an identity element. However, it is not commutative (since $b\cdot c\neq c\cdot b$) and it is not associative (since $b\cdot(c\cdot c)=b\neq a =(b\cdot c)\cdot c$).
Actually, given any set $S$ and operation $*$ on it (so possibly neither associative nor commutative), we can simply extend this with a new symbol $\color{red}0$ (i.e., $\color{red}0\notin S$) and on the set $S':=S\cup\{\color{red}0\}$ define an operation $\color{red}*$ by $$x\color{red}*y:=\begin{cases}x&\text{if }y=\color{red}0\\ y&\text{if }x=\color{red}0\\x*y&\text{otherwise} \end{cases}$$ Then $\color{red}*$ is not associative/commutative if $*$ is not associative/commutative. But $\color{red}0$ is neutral.