Solving matrix equation $XA=AY$ with known $X$ and $Y$ I am having problem in solving set of matrix multiplication.
There are three matrices $A,X$ and $Y$, all are non-singular $2\times 2$ matrices. Where matrix $X$ and $Y$ are known and $A$ is unknown. 
$$ X = \begin{bmatrix} x_{11} & x_{12} \\ x_{21} & x_{22} \end{bmatrix} $$
$$ Y = \begin{bmatrix} y_{11} & y_{12} \\ y_{21} & y_{22} \end{bmatrix} $$
$$ A = \begin{bmatrix} a_{11} & a_{12} \\ a_{21} & a_{22} \end{bmatrix} $$
and multiplication is as follows
$$ X\cdot A=A\cdot Y $$
I expanded it and tried to solve it as such I would be able to get elements of matrix $A$ at the end but it end up in homogenous linear equation having trivial solution zero. That makes all calculation meaningless.
$$ X\cdot A - A\cdot Y = 0 $$
What is the better way to compute it as such I can find result of matrix $A$ (in terms of elements of matrics $X$ and $Y$) at the end.
 A: See The theory of matrices, chapter VIII.  
A: In attempting to give you my complicated general formula to your question, a curious thing happened. All the zero terms made everything dissapear. This makes sense as $\mathbf{0}$ is obviously a solution. For a non-zero solution, $X$ and $Y$ must be similar matrices
$$XA=AY \Rightarrow A^{-1}XA = Y$$
Mainly for reference purposes, and to illustrate the subtle complexity of the equation, here is the $2 \times 2$ general form of the equation along with the solution (I used my own variables as I did not want to translate what I have, and the zeroes are the terms I mentioned):
\begin{array}{rcl}
\pmatrix{e & f \\ g & h}\pmatrix{q & r \\ s & t}=\pmatrix{q & r \\ s & t}\pmatrix{a & b \\ c & d}   \\
\Rightarrow \pmatrix{q & r \\ s & t} &= & \pmatrix{\hat{q}\over {\Delta} & \hat{r}\over {\Delta} \\ \hat{s}\over {\Delta} & \hat{t}\over {\Delta}} \\
\end{array}
with
$$\Delta = a^2\left(d^2 -de -dh + eh -fg \right)
 + a\left(-2bcd + bce + bch -d^2e -d^2h + de^2 + 2deh + dh^2 -e^2h + efg -eh^2 + fgh \right)  + bc\left( bc + de + dh -e^2 -2fg -h^2 \right)
 + d\left(deh -dfg -e^2h + efg -eh^2 + fgh \right)
 + e^2h^2 -2efgh + f^2g^2 $$
$$\hat{q}  =  0 $$
$$\hat{r} = 0 $$
$$\hat{s}  =  0 $$
$$\hat{t}  = 
 0 $$
The formula for $\Delta$ here is a test for equal eigenvalues - it is zero if $X=\pmatrix{e & f \\ g & h}$ and $Y=\pmatrix{a & b \\ c & d}$ share at least one eigenvalue(not necessarily all eigenvalues).
Therefore, if $\Delta$ is non-zero, there is not a solution to your equation. 
tl;dr: If you attempt to solve the equation by looking at the individual terms and getting simultaneous equations, you will be re-inventing a wheel called the Kronecker product. It is the tool you want to learn for this equation.
