Render an entity in a string and return it through an AJAX callback in a custom form
The code in my question is OK. The problem was caused by a conflict by calling the form from hook_preprocess_field(). I changed the hook, and I am calling the form from template_preprocess_block() and the AJAX callback of the entity gets fine.

4k4 put me on the right track. Thank you.