Why is it that every time I try to heat raw milk in a microwave it curdles and becomes like ricotta after a few seconds?
The problem you are facing is that your microwave temperature is too high and boils your milk too rapidly. The microwave does not heat food evenly and boils the milk too fast. Milk shouldn't be boiled too rapidly and doing this causes the casein in it to clump together and that curdles the milk. It should instead be brought 'to a boil' by heating on a slow heat for longer until it starts to boil.
So, you can try a couple of different options:
You can bring the milk to a boil in a pan on a stove on slow heat, which will take long depending on the amount of milk. And I can vouch for this method. I've seen my dad do this for years and as long as your pan is clean and the heat is low, you'll have a successful result.
I haven't tried this myself, but you can
Pour milk into a microwave-safe container and microwave on medium-high (70%) power, stirring every 15 seconds, just until steam begins to rise from the milk. To scald milk for custards or yogurt, heat 250 mL (1 cup) on HIGH for 2 to 2 1/2 minutes.- Reference
I have the same issue and it is NOT because the milk has approached the expiration date when it's a day old or too high of a microwave setting when it dues thus randomly. What I've found is that it may be a chemical reaction with the rinsing agent in your dishwasher and milk.
As other answer says, you need to lower down power of your microwave. But if the minimal power is still to high (it can happen if you trying to heat very small amount of milk) use the lifehack: additionally put a glass of water into the microwave, it will absorb sufficient part of power.
Check the temperature/heat rating that you are setting on the microwave. Very likely its a bit too high and that's the reason why it has a similar reaction as to when lemon juice or vinegar is added to milk.