Discrete valuations <-> points on a curve
For a nonsingular projective curve over an algebraically closed field, there is a one-one correspondence between the points on it, and the discrete valuations of the function field (i.e. all the meromorphic functions of the curve). The correspondence is point P -> the valuation that sends a function f, to the order of zero/pole of f at P.
Maximal ideals <-> points on a curve
At least for varieties (common zeros of several polynomials) over an algebraically closed field, there is a one-one correspondence between points on it, and the maximal ideal in $k[x_1,\cdots,x_n]$. The correspondence is point $P = (a_1,\cdots,a_n)$ -> the polynomials vanishing at P, which turns out to be $(x_1-a_1,\cdots,x_n-a_n)$. This is something true not only for curves, but for varieties. (Hilbert's Nullstellensatz)
So putting these together, for nonsingular projective curves over an algebraically closed field, you know that there is a one-one correspondence between the maximal ideals (think them as points) and the discrete valuations of the function field. Now the situation here is analogous. You consider a "curve", whose coordinate ring is $\mathbb{Z}$, with function field $\mathbb{Q}$. The nonarchimedean valuations correspond to discrete valuations in this case. So they should capture order of zeros/poles at some "points". What are the points? They should correspond to the maximal ideals of $\mathbb{Z}$, which are exactly the primes here.
As for $K(x)$, look at it as the function field of $K\mathbb{P}^1$. Just like the usual real/complex projective spaces, you should have two pieces here. Let's say $K[x]$ corresponds to the piece where the second coordinate is nonzero. So the corresponding homogeneous coordinates here is like $[x,1]$. We know there is one point missing, which is $[1,0]$. For this, we change our coordinates $[x,1] \to [1,1/x]$, so the piece where the first coordinate is nonzero should be $K[1/x]$. The missing point corresponds to the ideal $(1/x - 0) = (1/x)$, so this is why the infinite place corresponds to (1/x). Of course, a more straight forward interpretation is that for a rational function, you divide both numerator and denominator sufficiently high power of $x$ so that they both become polynomials in 1/x, have nonzero constant term, with an extra term (x to the some power). The infinite place measures this power.