What year?
I guessed 2011 on rock auto.
looks like the ballasts use a different connector than the h7 halogen low beams (not surprising)
looking at it, i believe it is a yazaki brand 090II sealed 2p. So you’d need the 2s connector to mate.
corsa-technic is who I buy from for Japanese stuff like that, looks like they have kits for 3.30$
You need to know how to crimp terminals like that to use those kits.
They are very similar to Aptiv/Delphi GT 280 or Metri pack push to seat stuff.
Cant quite tell if those lights/ modules have auto leveling if so you may need to disable it or add the sensor.
I haven’t done this on a Mazda, this is just me looking at it for 15 mins. Like folks said it would be good to go to a Mazda forum and see if someone has done a guide for this. I’d guess stuff exists for the speed3 enthusiasts and they use very similar lights