For some extra context: I think this is related to a known and documented limitation (though the docs are easy to miss). The docs on aggreation have this section (copied from Django 4.2 docs):
Combining multiple aggregations
Combining multiple aggregations with annotate() will yield the wrong results because joins are used instead of subqueries:
>>> book = Book.objects.first()
>>> book.authors.count()
2
>>> book.store_set.count()
3
>>> q = Book.objects.annotate(Count('authors'), Count('store'))
>>> q[0].authors__count
6
>>> q[0].store__count
6
For most aggregates, there is no way to avoid this problem, however, the Count aggregate has a distinct parameter that may help:
>>> q = Book.objects.annotate(Count('authors', distinct=True), Count('store', distinct=True))
>>> q[0].authors__count
2
>>> q[0].store__count
3
This documentation is about aggregates that produce joins in an annotation, but I suspect essentially the same happens for annotations that produce a join by themselves, like the OP's example.
Another way to circumvent the limitation (though it might not be applicable to the OP's problem) is to put the aggregate in a subquery. I previously explained how to use the django-sql-utils package for this:
For anyone else running into this, a reasonable workaround seems to be to use subqueries for aggregating annotations. This is a bit verbose/hacky in Django currently, as shown by the multitude of approaches in the stackoverflow link from Antoine's comment. However, I've successfully used the django-sql-utils package for this just now. That sounds a bit bulky, but it just has two utilities, one of which is a SubqueryAggregate class (with derived SubqueryCount, SubquerySum, etc.) that make converting a regular joining aggregate into a subquery aggregate easy and concise, without changing the structure much.
For example taking the example from comment 66 and converting the second annotation to a subquery with django-sql-utils, you'd get:
Branch.objects.annotate(
total=Sum('center__client__loan__amount'),
repaid=SubquerySum('center__client__loan__payment_schedule__payments__principal'),
)
There is also a bug report tracking this limitation. The OP's code is a bit more like this bug, which was closed as a duplicate of the first one.