HINT $\;$ Work "generically", i.e. let the entries $\;\rm a_{i,j}$ of $\rm A\;$ be indeterminates and work in the matrix ring $\rm M = M_n(R)\;$ over $\;\rm R = {\mathbb Z}[a_{i,j}]. \;$ We wish to prove $\rm B = C$ from $\rm d B = d C$ for $\rm d = det A \in R, \;\; B,C \in M.$ But this is equivalent to $\rm d b_{i,j} = d c_{i,j}$ in the domain $\rm R = {\mathbb Z}[a_{i,j}]$ where $\;\rm d = det A \ne 0$, so $\rm d$ is cancelable, yielding $\rm b_{i,j} = c_{i,j}$ hence $\rm B = C$. This identity remains true over every commutative ring $\rm S$ since, by the universality of polynomial rings, there exists an eval homomorphism that evaluates $\;\rm a_{i,j}\;$ at any $\;\rm s_{i,j}\in S$.
Notice that the crucial insight is that $\;\rm d,\; b_{i,j}, \; c_{i,j}\;$ have polynomial form in $\;\rm a_{i,j}$, i.e. they are elt's of the polynomial ring $\;\rm R = {\mathbb Z}[a_{i,j}] = {\mathbb Z}[a_{1,1},\cdots,a_{n,n}]$ which, being a domain, enjoys cancelation of elts $\ne 0$. Working generically allows us to cancel $\rm d$ and deduce the identity before any evaluation where $\rm d\mapsto 0.$
Such proofs by way of universal polynomial identities emphasize the power of the abstraction of a formal polynomial (vs. polynomial function). Alas, many algebra textbooks fail to explicitly emphasize this universal viewpoint - leaving students often struggling with alternative dense topological approaches.