A restaurant could certainly invest in avoiding the smell escaping. But for most people smelling it, it's advertising, not a beneficial service. (Hey, just like some services you can either pay for -or- have ads when using! LOL)
Moreover, preventing the smell from escaping from a restaurant might be difficult in areas or times where A/C isn't as common...
Free grazing was a thing in the USA until the invention of barbed wire. If you can't avoid free riders because costs of doing it are too high, you'll have to bear with them, at least until you find a cost efficient solution. Don't ask for others to subsidize you (i.e. making people who doesn't benefit from the smell pay for it).
Moreover, preventing the smell from escaping from a restaurant might be difficult in areas or times where A/C isn't as common...