I am new to type theory.
It was explained that $\Pi$-type is like cartesian product of types.
Firstly, in set theoretic formalization of mathematics,
a function $f$ from $\mathbb{N}$ to $\mathbb{R}$ is defined as
a subset of cartesian product of $\mathbb{N}$ and $\mathbb{R}$,
so the corresponding notation is $f \subseteq\mathbb{N} \times \mathbb{R}$.
However, in type theoretic point of view,
if a term $f := \lambda x.y$ has the type $\mathbb{N}\rightarrow\mathbb{R}$,
which is equivalent to the type $\Pi x:\mathbb{N}.\mathbb{R}$,
the notation becomes $f \in\mathbb{N} \times \mathbb{R}$,
if one interprets 'a term $t$ has a type $A$' as 'an element $t$ is in a set $A$'.
So it seems to me that two statements
'Pi-type is like cartesian product'
and
'function is subset of cartesian product'
contradict.
Then my question is,
in what sense Pi-type is like cartesian product?
What is the difference of the two points of view?
I think your misunderstanding might be right there. $\Pi x:\mathbb{N}.\mathbb{R}$ isn't the product of $\mathbb{N}$ and $\mathbb{R}$, but rather the product of $\mathbb{N}$ copies of $\mathbb{R}$. Written set theoretically, it's $\mathbb{R}^\mathbb{N}$, which is indeed (isomorphic to) the set of functions from $\mathbb{N}$ to $\mathbb{R}$.
$\Pi$ types are more general than this, though, since the type on the inside can refer to the argument. For example, if $\mathrm{Fin}(n)$ is the finite type with $n$ elements, $\Pi n:\mathbb{N}.\mathrm{Fin}(n + 1)$ is the type of functions whose input is a natural number $n$ and whose output is an element of the type $\mathrm{Fin}(n)$.
Set theoretically, $\Pi n:\mathbb{N}.\mathrm{Fin}(n + 1)$ corresponds to the product $\{0\} \times \{0, 1\} \times \{0, 1, 2\} \ldots$ of non-empty standard finite sets.