IOC and their sponsors make money from the Olympics, the athletes make profit too, big stars get big contracts and in most cases Top 8 finish or something gets you national funding for the next Olympic cycle. The only entity of the Olympics that doesn't make profit is actually the hosting city itself. I fully expect Baku and Doha hosting the Summer Games within the next 30 years. These are two venues that don't care about the financial loss and would go places to show themselves off to the world.
Hell, Baku has hosted the European Games back in 2016 already so they're moving up the ladder to bid for the SOG sooner than you think. Doha has hosted or will host senior World Championships in football, athletics, swimming, handball, cycyling, gymnastics, weight-lifting so just about any traditional Olympic sport there is. Their only goal left is to host the Summer Olympics and it's only a matter of time when they do.