The biggest cost difference between freelancers and agencies comes from overhead. A freelancer charges for development time only. An agency adds project management, sales, office costs, and profit margin — typically 2-3x the actual development cost.
This does not mean agencies are always worse. For complex projects requiring multiple specialized developers (frontend + backend + DevOps + designer), an agency provides team coordination that a single freelancer cannot.