Can iPhone get damaged by magnets in case? I got a Mous case which is great in terms of protection  against falls etc.
However it’s got magnets inside for accessories like to attach it to a car dashboard etc.
Can these magnets damage the phone’s component?
I’m asking because I know usually magnets aren’t good for electronics but especially because it’s now 2 iPhone XRs that I have that keep doing the same crap: randomly slowing down and or crashing. Especially when trying to take a photo or loading some apps but also sometimes just out of nowhere as I’m chatting in WhatsApp.
The first time I got a replacement at the Apple store cause they said the motherboard had a defect. But now this one is doing the same all over again since I got it.
So I’m wondering if that could come from the magnets.
Didn’t get the chance to test with another case and can’t try without a case, I’m too clumsy.
I’m asking cause I know usually magnets aren’t good for electronics

Magnets aren't good for magnetic media but have no effect on the electronics of your device.  In fact, you will find very strong magnets in Apple products like...

the lids of MacBook laptops
the covers of the iPad Accessories like the smart cover
around the edge of the iPad and iPad Pro to secure the Pencil
magnetic mount accessories that secure the iPhone/iPad for viewing/use in the car or other locations (personal note:  I have a family member with these products and they work fine.)

Your question is very similar to the existing question Can magnets harm an iPad? but I wanted to address the issues you were having.

I’m asking because I know usually magnets aren’t good for electronics but especially because it’s now 2 iPhone XR’s that I have that keep doing the same crap: randomly slowing down and or crashing. Especially when trying to take a photo or loading some apps but also sometimes just out of nowhere as I’m chatting in WhatsApp.

Given that you've already taken it in and they said the logic board had a defect; let's assume they swapped it out.  It could be the following:

your digitizer (the screen input) may be failing.  It may be sending random erroneous input to the system.  If it's happening too quickly or too much, it may be overloading the iPad slowing it down or crashing the App.
the accessory may be interfering with the capacitive touch.  The digitizer requires something that conducts a small electrical charge (like your skin) or the fabric on those stylus.  The material used may be lightly conductive and inadvertently sending inputs to the device - try removing the cover/case
software update may need to be installed.
software or iOS may be corrupt (file corruption does happen).  Try doing a full factory reset and a reinstall of the OS.

I'm leaning toward an issue with the digitizer (it or the case) because this symptom says a lot:

when trying to take a photo or loading some apps but also sometimes just out of nowhere as I’m chatting in WhatsApp.

Magnets would corrupt and disrupt things, not open other apps. To get an app to open, you need something to send input to the phone telling it to launch (or switch to it if already open).  Assuming you don't have a preset Shortcut the only thing that would send that type of input is the digitizer.