You need to make the observation that A commutes only with itself (that is, with A) and I. Once this has been noted, it clearly follows that if A commutes with B then B must be a linear combination of the matrices that commute with A, that is, a linear combination of the matrices A and I.