Question: 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.

Answer: 
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](https://en.wikipedia.org/wiki/Octonion).
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$).