Yes, when you have many thousands of developers putting effort into a project for free, just for the love of building the OS or software, they tend to care about what they’re building and they also use the same product so they want it to be of high quality and safe.
Apple does it for the high profits.
Microsoft was created by a madman and windows is trying to compete with google as far as personal data collection these days, plus MS has a monopoly so they’re not required to give a damn to keep their customers.
Lots of people who build malware do it for the love of building malware.