A major part of the success of open source has been the fact that companies have the option to fork/tweak/sell the code. MongoDB has benefited from this as much as anyone. They gained the adoption levels they have now by advertising these exact benefits. Only later did they decide you need a commercial license to provide it as a service. How many companies would have thought twice about using MongoDB had they thought they would eventually have to pay for it and/or couldn't monetize it themselves?
Also, it's not like Amazon is not giving back to the open source community (https://aws.amazon.com/opensource/)