How do I retrieve an entity from an entity reference
Entities part: 

I think (as much you showed) your entity definition is wrong: 


Entity names should be always SINGULAR: Chemical, Element, Chemical Formula
Your Chemical Formula should have the ability to hold reference to MULTIPLE elements (H20 for example, has H and O elements). Which means you won't able to store this information in this entity table, but you will have to create an external table to hold this information. You can find example for this in core entities (like taxonomy_terms, if I remember good).
If you make this changes right, you won't have query anything, since the referenced entity ids (elements, chemical) will be present in your entity. 
You only have to load via EntityTypeManager.


Final hint again: always examine core / contrib entities. Node, Taxonomy terms are pretty good examples.