Way Of Writing Metric I am acquainted with writing a metric in the form of a matrix. 
I came across this expressions:
$$f^2(x,y)(dx^2+dy^2)$$
$$(sin^2\varphi)d\theta^2+d\varphi^2$$
What are those expressions? how did we get to those expressions? 
 A: Consider a (pseudo-)Riemannian metric g over a $n$-dimensional manifold $M$. In local coordinates $(x^1,x^2,...,x^n)$ over $U\subset M$, the metric can be written $$g|_U = g_{i,j}dx^i\otimes dx^j$$ (with Einstein notation). The local chart implies a basis $\{\partial_1,\partial_2,...,\partial_n\}$, where $\partial_i := \frac{\partial}{\partial x^i}$, of the tangent bundle $T_U M$ over $U$. It verifies $dx^i(\partial_j) = \delta^i_j$. The coefficients $g_{i,j}$ of the matrix $[g_{i,j}]$ you are looking for are given by $g_{i,j} = g(\partial_i,\partial_j)$.
Now you can try that with either coordinates $(x^1,x^2) = (x,y)$ or $(x^1,x^2)=(\theta, \varphi)$.
Side note : This is simply linear algebra. Let $\{e_1,...,e_n\}$ be a basis of a real $n$-dimensional vector space $V$. Let $\{e_1^*,...,e_n^*\}$ be its dual basis, i.e. $e_i^*(e_j) = \delta_{i,j}$. Then any vector $v\in V$ can be seen as a column $[v_i]$ of numbers given by $v_i = e_i^*(v)$. Also, any 1-form $\alpha : V\rightarrow \mathbb{R}$ can be seen as a line $[\alpha_i]$ of numbers given by $\alpha_i = \alpha(e_i)$. Also, if $g : V\times V \rightarrow \mathbb{R}$ is a scalar product, you can see it as a matrix $[g_{i,j}]$ given by $g_{i,j} = g(e_i,e_j)$. Finally a linear application $A : V \rightarrow V$ can also be seen as a matrix $[A_{i,j}]$ given by $A_{i,j} = e_i^*(A(e_j))$. And so on. So I think your problem was not so much about "differential geometry" but simply "linear algebra". I think most people are confusing a "vector" (which is a point of a vector space) and a "column vector" (which is a column of numbers representing a vector in a given basis).
Remark 1 : The elements $e_i^*$ of the dual basis are written $e^i$ in Einstein notation.
Remark 2 : Your $dx^2$ is what I write $dx \otimes dx$ and should not be confused with $dx^2 \in \{dx^1,dx^2,...dx^n\}$ nor with $dx^2 = 2xdx$.
