Let $(X,\mathcal{A},\mu)$ be a measure space, and let $f,g: X\to X$ be two measurable functions. Assume that the preimages of measurable sets are a.e. the same for $f$ and $g$, that is, $$ \mu(f^{-1}(A)\triangle g^{-1}(A)) = 0\quad\text{for all $A\in\mathcal{A}$}\tag{$*$} $$ (where $A\triangle B = (A\setminus B)\cup (B\setminus A)$ is the symmetric difference).
Question: Under which conditions on $(X,\mathcal{A},\mu)$ can we conclude that $f = g$ $\mu$-a.e.? What if we ask this question only for $g = \mathrm{id}_X$, the identity in $X$?
Note that this is not always the case: if $X = \{0,1\}$, $\mathcal{A} = \{\emptyset, X\}$ and $\mu(X) = 1$, then any two functions $X\to X$ satisfy ($*$), but they can be different in every point (so take for example $f(0) = 1$, $f(1) = 0$, and $g = \mathrm{id}_X$). Of course in this case the problem is that the $\sigma$-algebra is trivial, so ($*$) is trivial. But what happens if, for example, $\{x\}\in\mathcal{A}$ for all $x\in X$? Or if the measure is non-atomic? Or in $[0,1]$ with the Borel $\sigma$-algebra and the Lebesgue measure (this is the case I'm most interested in)?
The only sufficient condition I've been able to get is "$\{x\}\in\mathcal{A}$ for all $x\in X$ and the only $\mu$-null set is $\emptyset$": in this case $\mu(f^{-1}(\{x\})\triangle g^{-1}(\{x\})) = 0$ implies $f^{-1}(\{x\}) = g^{-1}(\{x\})$, and therefore $f = g$ everywhere. But the second condition here seems too strong.
I would love a characterisation of this property, but of course some sufficient conditions would be great, especially if they apply to $[0,1]$.