Before 11.2 when updating an entity with a reference field via JSON:API the target entity would be set to the main property of the reference field, which generally is target_id. To support, for example, the use case of Entity Reference UUID this was changed to instead set the (computed) entity property. Having this (computed) property was already a requirement for reference fields so the only added assumption is that setting that property leads to the correct value being synchronized to the target_id property (or the target_uuid property in the case of Entity Reference UUID).
So to work with JSON:API any custom entity reference implementation must ensure that doing $item->entity = $target_entity; leads to the correct value being stored in the non-computed property (or properties). This also improves the developer experience for usage outside of JSON:API.