Two key mechanisms of disambiguation come to mind:
- Using hic (latter) and ille (former) is one way. Simple example: "A and B meet. The former eats, the latter drinks." — A et B conveniunt. Ille est, hic bibit.
- The pronoun se/suus usually refers to the subject of the sentence. Simple example: "B wrote a book. A compares his own book with B's." — B librum scripsit. A librum suum cum libro eius comparat.
Unfortunately there are cases where se/suus refers to something other than a subject.
The risk of misinterpretation is larger than usual in your story, but I guess that is inevitable if you want to use pronouns only.
On the other hand, "comparing X with Y" does not change much if X and Y are interchanged.
Despite the caveat, I think the distinction is best made with the pair suus/eius.
Here's how I'd translate your story:
Aeneas librum scripsit.
Deinde Brutus librum scripsit.
Deinde Aeneas contemplationem libri Bruti scripsit,
in qua librum suum cum libro eius comparavit.
There are better translations for "review" than contemplatio, but I decided to let the original translation stay here as its beside the point.
For a more on book reviews, see this follow-up question.
Incidentally, the specification "same gender" in the question is irrelevant for Latin here.
The the form of the pronoun suus depends on the thing possessed, not the possessor, and the genitive eius is the same for all three genders.
English makes a distinction between "his" and "her(s)", but Latin doesn't.
Regarding other languages:
Many languages have something similar to the Latin suus.
Italian has "suo", Swedish has "sin", Finnish has "-nsA", but there are syntactical differences between the languages.
However, to make the distinction clear in any language, I would simply repeat B's name on the last line.