There is a discussion of this issue in Dieudonné's History of Functional Analysis, p. 115:
It may seem obvious to us that the results of Hilbert are but one step removed from what we now call the theory of Hilbert space; but if, in fact, the birth of that theory almost immediately followed the publication of Hilbert's papers, it seems to me that it is due to the fact that this publication precisely occurred during the emergence of a new concept in mathematics, the concept of structure.
Until the middle of the XIXth century, mathematicians had been dealing with well determined mathematical "objects": numbers, points, curves, surfaces, volumes, functions, operators. But the fact that algebraic manipulations on different kinds of "objects" had a strikingly similar appearance soon attracted attention (cf. chap.IV, §3), and after 1840 it gradually became clear that the essence of these manipulations did not lie in the nature of the objects, but in the rules to be followed in handling them, which might be the same for very different types of objects. However, a precise formulation of this idea had to wait for the adoption of the set-theoretic concepts and language; and it is only in 1895 that our definition of a group, on an arbitrary underlying set, was formulated by Weber [225]. The trend towards the definition of algebraic structure then gained momentum, and around 1920 all fundamental notions of present-day Algebra had been defined.
In Analysis, no similar development had yet occurred in 1900. The extensions of the ideas of limit and continuity which had been formulated always were relative to special objects such as curves, surfaces or functions. The possibility of defining such notions in an arbitrary set is an idea which undoubtedly was first put forward by Fréchet in 1904 [69], and developed by him in his famous thesis of 1906 [71].
If I may summarize: the idea that one should talk about mathematical objects in terms of the axioms they should satisfy was itself quite new around 1900, and the specific application of this idea to the triangle inequality seems quite likely to have originated with Fréchet for that reason.