Infra is hard to get right, to change, and standardize.
That's why people use cloud providers, but they are very expensive.
With code, you can solve problems using cheap fleets of heterogenous vps from different providers.
And when you have a small budget, that makes a x10 difference in hosting cost. Not to mention you don't need to hire a super dupper 300k <cloud brand> expert to manage your system, a regular dev will do.
Most products don't need unlimited scaling, zero downtime and so on. It can even crash in prod once in a while, espacially in the early years.
You can alway migrate from code to infra later when you need to scale up and standardize. The opposite is way harder, if you even reach the point at all.
E.G: on a video streaming plateform with a decent audience (800k users a day), we had to transcode user uploaded videos then ensure we had several copies of them load balanced accross more or less servers depending of the media popularity. Today you would put some web scale key value store to manage that, maybe a cloud virtual FS or at least some CDN. At minimum, you'd spawn docker instances, kubernatis if you feel fancy. We solved the problem with redis, nginx and the cheapest naked vps possible. The site ran using only 7 servers, including encoding, streaming, database and the django app itself and was super fast.
To this day it is still maintained by one single dev working part time. It's 10 years old and still uses python 2.7, jquery and a hellish handcrafted css mess.
So sure, infra is the clean solution. But Pareto has something to say about it.