Companies do not necessarily make money from exclusively selling the code, but from services surrounding it. Consider hosting, support, implementation, management, training, certification or customization.
The open license and the business model are two different layers.