I have background of linear algebra but am still confused about the definition.
Suppose $\{\mathbf{x_1}, \cdots, \mathbf{x_n}\}$ and $\{\mathbf{y_1}, \cdots, \mathbf{y_m}\}$ are bases of vector spaces $X$ and $Y$, respectively. Then every $A \in L(X, Y)$ determines a set of numbers $a_{ij}$ such that
(3) $A \mathbf{x_j}=\sum_{i=1}^m a_{ij}\mathbf{y_i}$ $(1\leq j \leq n)$.
It is convenient to visualize these numbers in a rectangular array of m rows and n columns, called an m by n matrix: $[A]=\begin{bmatrix}a_{11} & a_{12}& \cdots & a_{1n} \\ a_{21} & a_{22}& \cdots & a_{2n} \\ \cdots \\ a_{m1} & a_{m2}& \cdots & a_{mn} \end{bmatrix}$
I have a counter-example against eq(3): $\mathbf{A}=\mathbf{I}$, $\mathbf{x_i}=\mathbf{e_i}$, $\mathbf{y_i}=\mathbf{-e_i}$.
My question is how shall I understand the definition?
This is no different from the standard method to convert between a linear map and a matrix, given fixed bases of the domain and codomain. In your case (take $m = n = 3$ for example), you have \begin{align*} \mathbf{A}\mathbf{x_1} &= \mathbf{I}\mathbf{e_1} = \mathbf{e_1} \\ &= (-1)(-\mathbf{e_1}) + 0(-\mathbf{e_2}) + 0(-\mathbf{e_3}) \\ &= (-1)\mathbf{y_1} + 0\mathbf{y_2} + 0\mathbf{y_3}, \end{align*} which makes $a_{11} = -1$, $a_{21} = 0$, and $a_{31} = 0$, from the given definition. This defines the first column to be $$\left(\begin{matrix}-1 \\ 0 \\ 0\end{matrix}\right.$$ Similar computation reveals that $$[\mathbf{A}] = \begin{pmatrix}-1 & 0 & 0 \\ 0 & -1 & 0 \\ 0 & 0 & -1 \end{pmatrix},$$ i.e. the negative identity matrix, as Berci predicted in the comments.
This procedure should always work; $\mathbf{A}\mathbf{x_i}$ is an element of $Y$, and thus can always be expressed as a unique linear combination of the basis $\mathbf{y_1}, \ldots, \mathbf{y_m}$. So, the $a_{ij}$s will always exist and be unique (for fixed linear transformations and bases).