Your first formula is correct, it is just similar triangles, simulating a Thin Lens model (single lens element).
Object size in image / object size is obviously always the exact magnification.
And the first formula equating that magnification to focal length / object distance is generally correct, except that we don't know focal length. The marked focal length applies to an infinity focus, and at macro focus, it is longer. In fact, at 1:1 focal length is generally 2x the marked number (but modern macro lenses use internal focusing which shifts things a small bit).
This first formula could compute focal length, knowing magnification and object image size (in mm). And then, knowing focal length, the first formula is valid (except object distance is still measured to the unknown internal node).
FWIW, for general lenses, Field of View and Depth of Field calculations also use the Thin Lens (similar triangles) model, using marked focal length and subject distance actually to an lens node, which is generally internal except in telephoto lenses, it is at the front of the lens (definition of telephoto), and in wide angle lenses in SLR, it is well behind the lens, to move lens forward to leave room for the SLR mirror to rise. In a 60 mm macro lens, it is somewhere probably around the middle of the lens.
Otherwise, subject distance in regular photography is measured to the sensor plane (or film plane if you prefer). But the similar triangles in the first formula is instead measured to a node inside or near the lens (Thin Lens properties).
The second formula just tries to state that difference, referring to the focal length node.
There is a macro property called Working Distance, which is 1:1 object distance measured from the front of macro lenses, determined for specific lenses by amateurs measuring it instead of the factory.
http://www.jeffree.co.uk/pages/macro-lens-calcs.html is a good sample.
But the Thin Lens similar triangles are measured from internal nodes (probably internal) instead of the front of the lens.
Further distance is less magnification. Magnification at infinity is zero (too small to see, unless bright like stars, where we can see the bright, but not the size).
Conversely, general lenses (as opposed to macro lenses) don't focus much closer than about 0.1x magnification, because the focal length and f/number become awkwardly larger at closer focus.