The "cloud" provided by AWS is cheaper -- if you use the higher-level AWS portfolio of services . E.g. DynamoDB, Redshift, Kinesis, etc.
If the mental model of "cloud" is just "bare metal servers", aka EC2, then AWS is more expensive than self-owned datacenters.
So yes, if you're only looking at cpu and egress costs, AWS as a "dumb data center" is a terrible deal. But that's not how Pinterest uses AWS. They use AWS high-level services:
E.g. they use AWS Rekognition -- machine learning service to annotate images with text : https://aws.amazon.com/solutions/case-studies/innovators/pin...
Pinterest also tried self-hosted Elasticsearch but it cost them more money than AWS Elasticseaerch: https://aws.amazon.com/solutions/case-studies/pinterest-elas...
(Yes, those are AWS marketing articles but writing those case studies require cooperation and approval by the customer (Pinterest in this case.).)
So far, Pinterest concluded it would not be cheaper to build their own machine learning algorithms to process images. Paying for AWS Rekognition is part of the ~$400m/year cost.