How long has AWS been selling compute by the second?
This is just price comparison. There are other reasons, convenience, visibility, integration with other services, to choose lambda sometimes and EC2 other times.
It's important to profile and know what your use case is!
Disclaimer: I work at Cloudflare on R2 and Workers is even cheaper than Lambda@Edge (provided your workload fits within the compute envelope). Billing is based on CPU time not wall time [3]. Workers Bundled pricing can be more cost effective in some cases if you only need <= 50ms of compute.
[1] https://lumigo.io/blog/aws-lambda-vs-ec2/ [2] https://www.trek10.com/blog/lambda-cost [3] https://blog.cloudflare.com/introducing-workers-unbound/