If you had 2 original keys, there's a procedure to follow to program a 3rd key.
With only 1, you need an OBD2 Adapter & FORSCAN to program the chipped keys in the antitheft system.
You can purchase used Mazda 5 keys from a scrapyard and the remote part can be programmed for the doors, plus I also discovered the chip be reused too instead of the generic cloned one from an ebay/amazon/aliexpress key.
I was able to program my 3rd key & remote using info from this site:
Find out how you can program a new Mazda key yourself without the need of a car locksmith. Where to buy a new Mazda key and how to program it.
nikolay100.com