Milk and other milk products contain casein, the primary protein compound in milk. When the environment becomes acidic, casein causes the liquid to curdle, like when milk goes bad. The same thing happens when you add lemon to milk.  To avoid this, you have to boil the milk with the other ingredients first and leave it for 5 minutes to cool down. Add your lemon juice slowly while stirring constantly, and let the mixture rest once the lemon juice has been completely incorporated. Let cool completely, mix one last time, and you’re done.