The geometric turn recorded in Euclid comes with late Pythagoreans, it is likely that it was prompted by the discovery of incommensurability. Early Pythagoreans, like ordinary Greeks, did not represent natural numbers by line segments even if they arranged them into geometric shapes (anecdotally, Pythagoras used pebbles). In fact, they tried to reduce everything, including geometry, to natural numbers and their ratios. Even the original even/odd proof of incommensurability might have been arithmetical in nature, see Fowler. Books VII-IX of Euclid's Elelments are generally attributed to early Pythagoreans, who knew four out of five Platonic solids even before Theaetetus, so plane and solid numbers were likely considered already by them. Late Pythagoreans, like Archytas of Tarentum, were already quite adept at dealing with surfaces and curves produced by their intersections. Unfortunately, the sources for pre-Euclidian period are too scarce to say much more than that.
As for Babylonians their system of numerals was positional with base $60$ and excellent for doing calculations, which they were very good at, even their astronomical models used numerical sequences rather than geometry. So they are much more likely to have found small Pythagorean triples by numerical experimentation and then figured out the pattern without squares or triangles. A suggestion of Robson based on refined translations is that for pedagogical purposes they were interested in reciprocal pairs of numbers $x=p/q$ and $y=q/p$ with only $2,3,5$ (divisors of $60$) as prime divisors of $p,q$. Pythagorean triples then come as a side effect: if $xy=1$ then $1+\big(\frac{x-y}{2}\big)^2=\big(\frac{x+y}{2}\big)^2$, and in terms of $p,q$ we get the formula for the triples.