My understanding is that the span of a set is a set of all vectors that can be obtained from the linear combination of all the vectors in the original set as shown in image #1.

What I do not understand is how the span (or the dimension of span) of a set consisted of rows of a matrix is related to its rank, as shown in image # 2.

I always thought that rank is related to the basis of a set of vectors, not its span.
Thanks
Matrix rank shows how many linearly independent vectors there are in the matrix. And when determining the span you don't really need any other vectors (linearly dependent vectors are also in the span since they can be formed by linearly independent ones).
The dimension of span is the number of vectors which form that span, so it makes sense that it's formed by only independent vectors of a matrix. Therefore: $dim C(A) = rank A$.
And since in any matrix the number of independent vectors in rows is the same as in columns: $dim R(A) = rank A$ too.