Yes, but many of their efforts don’t make much sense that way. The Index and Alyx made them some money, but were they the best use of Valve resources in terms of profit, even without the benefit of hindsight? Nah. It was immediately obvious that it was closer to a passion project for them. It’s something they believed in and wanted to try, not something that was gonna make them richer anytime soon.
On the other hand, Valve has been on the forefront of adding microtransactions and lootboxes to their games, including paid games. They are not beyond optimizing for maximum profit even if it that mindset does not infect all of their projects.