Here's a more detailed breakdown of the equations and assumptions that went into this focal length calculator. I will use the same variable names from your post. All we need is the following equation:
Which simplifies to:
alpha/2 = arctan(s / (2*S2)) = arctan(h / (2*S1))
So far nothing has changed, but here's where your calculation begins to differ. You are assuming that S2 = focal length, which is an approximation for situations where the focusing distance is large compared to the focal length. S2 is more accurately defined as the distance from the sensor to the 2nd nodal point of the lens, which can be calculated from the following equation:
Very technical note: even the above equation makes an approximation by assuming that the entrance and exit pupils of the lens are located at the 1st and 2nd nodal/principal points. It is still an improvement though. Also, strictly speaking, D is the distance from the subject to the 1st principal point of the lens, not the distance from sensor to subject.
S2 = D*f / (D-f)
where: D = distance at which the lens is focused
Using the above improved approximation, the focal length can therefore be estimated using the following simplified expression:
Of course, in relative % error the difference between the improved approximation and your calculation is small for all practical purposes. However, the discrepancy increases as the focusing distance (D) decreases.
Let me also add that I can certainly make mistakes; although all calculators on this website were reasonably scrutinized, finding errors in them is not out of the question. If you notice something you think is in error, by all means bring it up in a discussion such as this one.