Motive 1: Politics and Public Perception
These big companies have a boost in the Public Perception after these announcements. This is important for them. Remember Google's motto used to be "Don't be evil", but not anymore.
You could argue that they have a need to steer the political discourse in their favor. For Example Google's Material Design is a political choice
Everything is very well documented and, with an “open source” rhetoric, they ensure that everyone practices their guidelines. And that can be a problem.
[...]
Google is a multinational corporation that represents a particular culture and Material Design is just another tentacle of the octopus that monopolizes the Web.
This general behavior in the Capitalist Economic Model is described and criticised in the documentary The Corporation
Motive 2: Practical Benefits of a Community of Users
A big driver is the long term benefit of having a large community of users testing and improving the software.
A good example would be the security aspect, as explained in How is open source encryption safe?
...Open source encryption is thus often more secure than non-open source encryption...
because:
Cryptographer Bruce Schneier explains:
Every secret creates a potential failure point. Secrecy, in other words, is a prime cause of brittleness—and therefore something likely to make a system prone to catastrophic collapse. Conversely, openness provides ductility.
Motive 3: Long Term Economic Benefits
Example 1: Google bought Android to have control over the mobile ecosystem and be able to have an audience for their mobile ads.
Example 2: Oracle buys Java (Sun Microsytems), then eventually sues Google over Java Copyright because they want to cash in on Android's popularity.
Example 3: The React's license change controversy that arose after the project had chosen to use a BSD-derived license that contained some troubling terms surrounding patent litigation. Then
Facebook re-licenses React under MIT license after developer backlash
Motive 4: Counter Existential Threats
Open Source Projects compete with Private initiatives, this can be illustrated by the infamous quote “Linux is a cancer” by Steve Ballmer.
Furthermore, you could analyse the "Embrace, Extend, Extinguish" strategy by Microsoft Bryan Lunduke at Linux Fest Northwest, April 28 2018 to understand the mindset of these big companies.