A oil filter doesn't know what engine its going on.
That being said,if all the internal specs are the same, the Toyota should fit the Mazda. This has been proven true by the M-1 and K&N being same filter for both.
I worked at NAPA for 10 years, had lots of conversations with the Wix, they make NAPA's filters, and if the specs are the same you can swap them no problem.
Example, a 1069,1060 and a 1794 all fit small block Chevys. The difference? 1069=1/2qt 1060=1qt 1794=2qts They all fit.
As vehicles got newer, filters got manufactored by a certain spec number. Most of the time that meant different outside sizes, but if you looked in catalogs at the filter specs, the type of media, thread size, sealing gasket , ADBV and the bypass PSI were the same. Each filter would hold more or less oil.
During farm filter days guys would bring list of oil filters for their tractors, combines etc, of different brands. JohnDeere, Case, CaseIH, International etc. You would not believe howmany oil filters you can consoldate to fit ALL their stuff, instead of having numerous filters for different tractors etc.
oldhp