Why does my ricotta cheese go bad in a few days?
Pasteurized ricotta should last 2-4 weeks in the fridge, unpastuerized 1-2 weeks.

So, A Few Possibilities:

Your fridge is way too warm, like close to room temperature.  Ricotta will spoil if left out at room temperature or warmer in a few days.  Have you checked fridge temp?  Where in the fridge are you storing the ricotta?

You have a lot of spoiled milk bacteria in your fridge.  If you've had dairy products go "off" many times in your fridge (or only once, but you spilled it), and not cleaned it, then you may have cultures of dairy-eating bacteria living in your fridge.  Do other dairy products spoil quickly for you?

Your ricotta vendor is contaminated.  If you've been getting all of this ricotta from the same store or the same maker, it's possible that their equipment/storage is contaminated.  Try a different source/store.

You are buying ricotta which is already old. When was this ricotta made?  How close is it to the expiration date when you buy it?