We can find matrix representation of operator $\hat{A}$ by following:
$$\hat{A}=I\hat{A}I=\sum_n \left| \phi_n \right>\left< \phi_n \right| \hat{A} \sum_m \left| \phi_m \right>\left< \phi_m \right|=\sum_n\sum_m \left< \phi_n \right| \hat{A} \left| \phi_m \right>\left| \phi_n \right>\left< \phi_m \right| \text{ (*)}$$ Now if we assume that $$\phi_1=\begin{bmatrix}1 \\0\end{bmatrix} \text{and }\phi_2=\begin{bmatrix}0 \\1\end{bmatrix}$$ We can see that $$\sum_n\sum_m\left| \phi_n \right>\left< \phi_m \right|= \begin{bmatrix}1 &1 \\1 & 1\end{bmatrix} $$
And thus $$\hat{A}=\begin{bmatrix}A_{11} & A_{12} \\A_{21} & A_{22}\end{bmatrix}$$
The question is, are orthogonal bases $\{ \left| \phi_n \right>\text{}\}$ arbitrary? Obviously, the only limition I can think of is completeness of $\{ \left| \phi_n \right>\text{}\}$. Because after all equation (*) needs nothing more than that. But if it's indeed arbitrary, then I will assume the following bases: $$\phi_1'=\frac{1}{\sqrt{2}}\begin{bmatrix}1 \\1\end{bmatrix} \text{and }\phi_2'=\frac{1}{\sqrt{2}}\begin{bmatrix}1 \\-1\end{bmatrix}$$ We can verify completeness of $\{ \left| \phi_n' \right>\text{}\}$ simply by
$$\sum_n\left| \phi_n' \right>\left< \phi_n' \right| =I \text{ and } \left< \phi_1' \middle| \phi_2' \right> = 0 $$
However, the problem arises when I try to compute the following:
$$\sum_n\sum_m\left| \phi_n' \right>\left< \phi_m' \right|= \frac{1}{2}\begin{bmatrix}1 \\1 \end{bmatrix} \begin{bmatrix}1 &1 \end{bmatrix} + \frac{1}{2}\begin{bmatrix}1 \\1 \end{bmatrix} \begin{bmatrix}1 &-1 \end{bmatrix} + \frac{1}{2}\begin{bmatrix}1 \\-1 \end{bmatrix} \begin{bmatrix}1 & 1 \end{bmatrix} +\frac{1}{2}\begin{bmatrix}1 \\-1 \end{bmatrix} \begin{bmatrix}1 & -1 \end{bmatrix} = \frac{1}{2}\begin{bmatrix}1 & 1 \\1 & 1\end{bmatrix} + \frac{1}{2}\begin{bmatrix}1 & -1 \\1 & -1\end{bmatrix} + \frac{1}{2}\begin{bmatrix}1 & 1 \\-1 & -1\end{bmatrix} +\frac{1}{2}\begin{bmatrix}1 & -1 \\-1 & 1\end{bmatrix} = \frac{1}{2}\begin{bmatrix}4 & 0 \\0 & 0\end{bmatrix} $$ But it's not good! Since in this case I have:
$$\hat{A}=\begin{bmatrix}2A_{11} & 0 \\0 & 0\end{bmatrix}$$
Because $\hat{A}$ is completely arbitrary, that would mean any operator in $\{ \left| \phi_n' \right>\text{}\}$ will take the form of $\hat{A}$ which doesn't seem to be correct intuitively at least. In Quantum Mechanics from Zettili, author has written equation (*) without mentioning $\{ \left| \phi_n\right>\}$ at all, which makes me think that $\{ \left| \phi_n \right>\text{}\}$ is indeed arbitrary, as we can see from (*) itself. But from above calculation, it seems as if matrix representation of operator $\hat{A}$ depends on $\{ \left| \phi_n\right>\}$. What am I missing here?