I am reading the definition of associative $R$-algebra, and am confused about the following definition from Wiki:
https://en.wikipedia.org/wiki/Associative_algebra
The first equality comes from the associativity of being an algebra.
However, how to obtain the second equality?
I believe $\mathcal{A}$ does noe have to be a commutative ring though $\mathcal R$ is a commutative ring.

There are two operations here: one is 'multiplication' of 'scalars' with algebra elements, denoted by dot, and the other one is the multiplication of the algebra, between two of its elements.
The axiom says: $$r\cdot(xy)=(r\cdot x)\,y=x\,(r\cdot y),\\ r\in R,\quad x,y\in A\,.$$
Since $R$ is commutative, its left action on $A$ can be mirrored to the right side by defining $a\cdot r:=r\cdot a$. This way you can also read it as $$r\cdot(xy)=(r\cdot x)y=(x\cdot r)y=x(r\cdot y)=x(y\cdot r)=(xy)\cdot r\,.$$