In Metric is continuous function, I found the following answer
Define $f:X\times X\to \mathbb R$ by $f(x,y)=d(x,y)$.
Let $(x_n,y_n)$ be a sequence in $X\times X$ such that $(x_n,y_n)\to (x,y)$
Then $(x_n)\to x,(y_n)\to y\implies d(x_n,x)\to 0 ,d(y_n,y)\to 0 $ as $n\to \infty\implies d(x_n,y_n)\leq d(x_n,x)+d(x,y)+d(y_n,y)\to d(x,y)$
$\implies d(x_n,y_n)\to d(x,y) $ as $n\to \infty \implies f(x_n,y_n)\to f(x,y)$
The above proof depends on the fact that the metric on $X\times X$ is so chosen that $(x_n,y_n)\to (x,y) \implies x_n \to x$ and $y_n\to y$. I have a query whether there is a metric on $X\times X$ so that the metric function $d:X\times X \to \mathbb{R}$ is not continuous.