How to implement conditional probability distribution on set-valued Random Variables
Your understanding of the basic situation (without sets) has some caveats.  It seems that you are defining
$$f(x,y) =  \Pr[X=x \land Y=y] \times |\mathcal{X}| \times |\mathcal{Y}|.$$
You seems to be assuming that $X,Y$ are independently and uniformly distributed over the sample space $\mathcal{X} \times \mathcal{Y}$.  Note that this is a big assumption -- it typically won't hold, and if it doesn't hold, your formula is not correct.
You don't need a fancy accumulator function. There is a simpler expression for $f$, namely, $f(x,y) = 1$ if $x \in \mathcal{X},y \in \mathcal{Y}$ (and $f(x,y) = 0$ otherwise, if you allow that to happen).  Again, this is only valid if $X,Y$ are uniformly distributed on $\mathcal{X} \times \mathcal{Y}$.
When $X,Y$ are sets, the exact same formula holds... under the same assumptions.  No changes needed at all.
Your proposed formulas (1), (2) are not correct.
In practice, usually $X,Y$ are typically not independently and uniformly distributed.  Therefore, these formulas are usually not useful in practice.  Instead, you need to work directly with the probabilities; counts and $f$ probably won't be useful in that case.