The Pauli matrices form an orthogonal basis of $\mathcal{M}_2$, this vector space can be endowed with a scalar product called the Hilbert-Schmidt inner product

$$ \langle A,B\rangle=\mathrm{Tr}(A^\dagger B)$$
since the Pauli matrices anticommute, their product is traceless, and since they are Hermitian this implies that they are orthogonal with respect to that scalar product, hence the decomposition noticing they have norm $2$ since their square is the identity.

More explicitely, if $$A=\alpha X +\beta Y +\gamma Z+ \delta I $$

then

$$\mathrm{Tr}(AX)=\alpha \mathrm{Tr}(X^2)+\beta\mathrm{Tr}(XY)+\gamma\mathrm{Tr}(XZ)+\delta\mathrm{Tr}(X)=2\alpha $$

and same for all the others