Toyota isn't going to "buy" Mazda. Mazda and Toyota is in the same "loose" business group.
The Japanese don’t like businesses that aren’t profitable. They want the business to make a “healthy” profit, which means enough money so you can still break even if you have a setback. They also look to the future, care for the health of the business, and unlike American investors, screw over the company for a short term stock price rise.
But it’s okay to make a few percentage points less and spend money on partnerships and other things that will build market share....things that look like an expense but translate into an investment.
I believe this is what is going on.
Mazda, is struggling on research and development, is under pressure to offer advanced environmental and safety technologies such as fuel-cell engines that run on hydrogen, as well as autonomous systems that increasingly will take over for drivers. Toyota is among the R&D leaders, so it can share with little additional cost.