How to estimate the conditional probability p(y|x) if y and x are both continuous but y is discrete given x? For example, $P(Y=f_1(x)|X=x)=g_1(x)$, $P(Y=f_2(x)|X=x)=1-g_1(x)$. (The functions f1,f2 are unknown and need to be learned.) How can I estimate such a conditional probability?
I guess that kernel density estimation (KDE) seems to solve such a problem, but I still want to find some alternative solutions. I'm a beginner in this field, and I appreciate any help (maybe the recommendation of some papers or books), Thank You!
And is it reasonable to approximate discrete variables as continuous variables with very concentrated probability densities and use some conditional density estimation methods designed for continuous variables to find the 'density' and do some normalization of the 'density' to get the probabilities?

You have to learn a possibly multimodal distribution $p(Y|X=x)$ for each $x$.
Ordinarily, one presumes that the distribution $p(Y|X)$ is normal and has a variance that is independent of $x$:
$$
p(Y|X=x) \sim N(\mu(x), \sigma^2).
$$
In your use case, this changes and you have to learn a distribution that is more complex, e.g. a mixture of Gaussians:
$$
p(Y|X=x) \sim \sum_{i=1}^k \pi_i(x) N(\mu_i(x), \sigma_i^2(x)).
$$
This is often done using density networks which are neural networks that do not just learn the mean of a distribution but actually all the parameters of a more complex distribution. I.e., in the above example of a Gaussian mixture, those neural networks are also called "mixture density networks" and they would learn the parameters $\pi_i(x), \mu_i(x), \sigma_i^2(x)$.
