We are unlikely to add much new to the discussion of why math works, but by exploring the issues, we might learn more about the question. For instance, Barry Etheridge pointed out that in some sense “No triangle exists out here” by the traditional definition of a triangle. There is a world of philosophical books hidden in that simple quotation, but let us consider it only from a physicist’s point of view.
A physicist would start by assuming there is a reality outside of human thought (particularly your own world of thought). This simple assumption might not be shared by all. Further, a physicist assumes that meaningful information about that reality can be obtained by making observations either directly through sensory input or mediated through instruments to sensory input. In making sense of certain observations, such as physical things that look like triangles, a physicist will note certain underlying and unifying characteristics such as the sum of the interior angles add to half of a full circle as nearly as can be measured for triangle-things big or small of any shape. This can lead to the supposition of a model of a true triangle. The benefit of working with a simplified model is that one can make exact calculations which can be tested in the real world to whatever the available accuracy is.
In this view, mathematics starts as a convenient model for organizing disparate observations in a particularly compact way. However, nothing says that we are limited in our thought processes to considering only the results of physical observations, so as we learn more about mathematics, its role as handmaiden to observations of the physical world is not necessarily the dominant one. To the extent that mathematics probably started in this heuristic way, the fact that is can be used to describe the universe as accurately as we wish is not surprising. What is surprising is that as mathematics grew, it was able to make provide tools for further description long before anyone thought those tools might actually be useful. And that does not even consider the inventions/discoveries that have no physical realization.
However, Barry also says that mathematics is not accurate. Here he goes astray by mixing the real world of physics with an ideal world of math. In the real world, we cannot have an exact measurement in the sense of an absolutely exact proof or representation of a transcendental number. We commonly refer to the infinite heavens, but a true mathematician would point out that infinity is something different that any observation we have ever made. A good mathematical model of reality usually predicts physical parameters much more accurately than we can measure. Some of the latest theories in physics predict parameters which have been measured to less than one part in a trillion with agreement well within the error bars.
None of this shines any light on whether a triangle has any reality beyond a physical approximation. However, we must be careful about not giving approximations the respect they deserve. All life is an approximation. There may or may not be a world of ideals (a la Plato), but for my (physical) money, there is certainly a physical world and we can greatly compress the observations of it by the appropriate use of mathematics. F = MA summarizes a lot of experimentation, and it is still accurate in the range of the observations on which is was derived where by accurate, I mean in the physical sense of being within error bars, not in the mathematical sense of being exact.
Mathematics: invented or discovered? Well, it depends…