Possibilities:
A truth, B truth - impossible, as this contradicts what A is saying
A truth, B lie - impossible. Any logical implication in the form $false \implies x$ is true for all x (see, e.g. https://math.stackexchange.com/questions/137890/why-is-it-sensical-for-a-proposition-with-a-false-antecedent-to-validate-to-true ). So since "the statement person A just made was false" is itself false, the entire statement can't be false, since it's in the form $false \implies (gold.buried.behind.church)$
A lie, B truth - possible, and the gold is buried behind the church
Both lie - impossible, as A would be telling the truth if B was lying
So the gold is behind the church.
Obviously, a big note to the above is it assumes that A knows what B is going to say in advance, and that the two will avoid logical paradoxes. Because, on a common-sense level, it's certainly physically possible for them to both say those statements even when there's no gold behind the church.
Likewise, if you say "Either this statement is a lie or I have a million dollars in my bank", the only non-paradoxical solution is that you have a million dollars... but that doesn't make it true!
To understand the false implies all thing, imagine somebody saying "if (thing that isn't true) then (some other statement)". Like, "if pigs can fly, then I can read minds". You can never call the person a liar for not being able to read minds, because pigs can't fly, so the overall statement isn't false.