Can a binary operation have an identity element when it is not associative and commutative? I tried getting the answers in similar questions, everyone says that it's not necessary, but if $e$ is the identity element for any binary operation $*$, which is not associative and commutative, how can
$$a*e=a=e*a$$
when it is not commutative, i.e. $a*b \ne b*a$?
Even if we get a value by solving $a*e=a$. Will we get the same value by solving
$e*a=a$ ?
Please provide an example.
 A: 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.
A: It is possible. $*$ not being commutative means that $a*b\neq b*a$ for some $a,b$, not for all of them. So you may have $a*e=e*a=a$ without contradicting that $*$ is not commutative.
A: Without looking for esoteric  and/or ad hoc examples, there is one you are certainly familiar with. The identity matrix is the identity element for matrix multiplication, which is not commutative. We have $A\,I=I\,A=A $ while in general $A\,B \neq B\,A $.
A: 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$). 
A: 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.
A: 
Can a binary operation have an identity element when it is not associative and commutative?

Yes. Any non-commutative loop is an example of such algebraic structure. I am surprised that, searching the word loop with Ctrl + F in this page just before answering, I found only one occurrence in the comment by Arthur.


(...) how can
$$a*e=a=e*a$$
when it is not commutative (...) ?

As in the accepted answer, the operation $*$ is by definition commutative on the set $A$, if and only if
$$
a*b=b*a
$$
for all $a,b\in A$.
No surprise if, in a given operation on a given set $A$, only some elements of $A$ commute with all the others: in a non-commutative binary operation with two-sided identity, the identity element commutes with all the others elements. Indeed, the definition of identity element $e$ for the binary operation $*$ on a set $A$ states:
$$
a*e=a=e*a,\quad\forall\,a\in A.
$$


Please provide an example.

Of course :) And, further, we can create without too much effort an example which is even less than a loop. The finite magma of order $4$ given by the Cayley table
\begin{array}{c|cccc}
* & 1 & 2 & 3 & 4\\
\hline
1 & \color{red}{1} & \color{red}{2} & \color{red}{3} & \color{red}{4}\\
2 & \color{red}{2} & 4 & 3 & 3\\
3 & \color{red}{3} & 3 & 4 & 2\\
4 & \color{red}{4} & 1 & 1 & 1\\
\end{array}
has the two-sided identity element $1$ while cancellation and division do not hold, it is not commutative since - e.g. - $2*4\ne 4*2$ and it is not even associative:
$$
(2*3)*4=3*4=2\ne 4=2*2=2*(3*4).
$$
A: Isn't subtraction a binary function which has an identity ($x-0=x$) although it is not commutative ($5-0 > 0-5$) or associative ($5-(4-3) > (5-4)-3$)?
