Suppose a regular polygon with $n$ side has radius (line from center to point that connect sides *I don't know how to call it) of length $r$.
From cosine law, the side would has length of $$\sqrt{2r^2-2r^2\cos( \frac{2 \pi}{n} )} $$
Perimeter would be $$\sqrt{2r^2-2r^2cos( \frac{2 \pi}{n} )} \times n $$
Circle has infinitely-many sides and circumference of $2\pi r$ So $$\lim_{n \rightarrow \infty} \sqrt{2r^2-2r^2\cos( \frac{2 \pi}{n} )} \times n= 2 \pi r$$
And $$\lim_{n \rightarrow \infty} \frac{\sqrt{2-2\cos( \frac{2 \pi}{n} )} \times n}{2}= \pi$$
But, when I plot it on Desmos, the graph scatters at $5.9\times 10^8$ (in the picture). Can anybody give me reason why this happens?
Doing a series expansion, $\cos(2\pi/n)=1-2\pi^2/n^2+o(1/n^2)$ so $\sqrt{2-2\cos(2\pi/n)}=\sqrt{4\pi^2/n^2+o(1/n^2))}=\frac{2\pi}{n}(1+o(1))$ and so $n/2$ times that is $\pi(1+o(1))$ i.e. it converges to $\pi$. Thus I conclude that the problem you are seeing on desmos is probably caused by numerical error due to catastrophic cancellation in the subtraction $2-2\cos(2\pi/n)$.
Accurately computing a difference of two numbers that are so close together using floating point arithmetic needs a special routine that computes the difference directly, rather than performing a subtraction at all. One way to do that for $1-\cos(x)$ is to use a trig identity, which I usually remember as $\sin(x)^2=\frac{1-\cos(2x)}{2}$ (I remember it this way because this is the form that comes up all the time in calc II). From here you have $1-\cos(x)=2\sin(x/2)^2$ which now doesn't involve subtracting nearly equal numbers. By using that identity, you might try plotting $x \sin(\pi/x)$ for large $x$, you should see a better result.