Purpose of Class Diagram vs real world code

In the class diagram, we have entities. We define attributes, methods on entities and then we define relationship between entities.
But in the real world application, when we code, we usually use the entities as either POCO or DTO (data transfer objects), and the business logic usually goes into the services part.
Why there is this mismatch ? What is the need of class diagrams then ? How to represent these services in the class diagrams ?