It is known that every 2-dimensinal Lorentzian manifold is conformally flat and in general it's not globally conformally flat.
(Here, globally conformally flat means there are a global coordinates system on a (Pseudo-Riemannian) manifold $(M,h)$ and scale function $\Omega:M\to R$ such that $\Omega h$ can be expressed as Minkowski metric in the coordinate.)
Nevertheless, in string theory book, Polyakov action is written globally in conformal gauge as,
$$\tag{1}S=\frac{T}{2}\int d^2\sigma(\dot{X}^2-X'^2)$$
where $T$ is constant, $X:I\times I\to \mathbb{R}^{1,d}$ ($I=[0,1]$ and a Lorentzian metric $h$ is given on $I\times I$) and (I think they suppose) there are $U\subset \mathbb{R}^2$ and a global coordinate system $\varphi :U\to I\times I$ on $I\times I$ and scale function $\Omega:I\times I\to\mathbb{R}$ such that $\Omega h_{\tau\tau}=-1,\, \Omega h_{\tau \sigma}=0,\, \Omega h_{\sigma\sigma}=1 $ with respect to the coordinate system. $\dot{X}^2$ means self inner product of $\partial \tau (X\circ \varphi)$ with respect to the metric of $\mathbb{R}^{1,d}$ and $X'^2$ does so.
At first I think $(1)$ doesn't mean that there is a global coordinates on $I\times I$ such that $h_{\tau\tau}=-1,\, h_{\tau \sigma}=0,\, h_{\sigma\sigma}=1 $ and $(1)$ holds in terms of partition of unity.
That is, there are coordinate neighbourhood system $\{\varphi_i:U_i\to U_i'\subset I\times I\}$ and scale function $\Omega_i: U'_i \to \mathbb{R}$ such that $\Omega_i h_{\tau_i\tau_i}=-1,\, \Omega_i h_{\tau_i \sigma_i}=0,\,\Omega_i h_{\sigma_i\sigma_i}=1$ and partition of unity $\{ \rho_i:U_i'\to\mathbb{R}\}$ (there is such coordinate neighbourhood system and scale function $\Omega_i$ because of conformally flatness) and Polyakov action can be expressed as
$$\tag{2}S=\frac{T}{2}\sum_i \int_{U_i'}d\tau_id\sigma_i\,\rho_i\circ\varphi_i(\tau_i,\sigma_i)\Bigg(\Big(\frac{\partial (X\circ \varphi_i)}{\partial \tau_i}(\tau _i,\sigma_i)\Big)^2-\Big(\frac{\partial (X\circ \varphi_i)}{\partial \sigma_i}(\tau _i,\sigma_i)\Big)^2\Bigg) .$$
However textbook says
Varying with respect to $X^\mu$ such that $\delta X^\mu(\tau_0)=0=X^\mu(\tau_1)$ (textbook uses $[\tau_0,\tau_1]\times[0,l]$ instead of $I\times I$) we obtain $$\tag{3}\delta S=T\int d^2\sigma \delta X^\mu (\partial _\sigma^2-\partial_\tau^2)X_\mu-T\left.\int_{\tau_0}^{\tau_1}d\tau X'_\mu \delta X^\mu\right|_{\sigma=0}^{\sigma=l}.$$
It can't be obtained from $(2)$ by integral by parts because of the term $\rho_i\circ\varphi_i(\tau_i,\sigma_i)$ (derivative of $\rho_i$ appears when one does integral by parts).
Question
Does string theory just consider metrics on world-sheet which are globally conformally flat?
Or is there way to get $(3)$ from (2)?
Edit
I came up with an idea. They probably take coordinate neighbourhood systems which satisfy $int(U'_i)\cap int(U'_j)=\emptyset$ for $i\neq j$ where $int$ means interior (e.g. each $U'_i$ is rectangle subset of $I \times I$). Then each $\rho_i=1$.
However surface terms like
$$\Big[\int d\sigma_i \delta X\cdot \partial \tau _iX\Big]_{\tau_i=0}^{\tau _i=t_i}+\Big[\int d\tau_i \delta X\cdot \partial \sigma _iX\Big]_{\sigma_i=0}^{\sigma _i=s_i}$$
appears from every coordinate neighbourhood. It's not obvious that these terms cancel each other.
Let's suppose each terms cancel each other. The textbook follows that from $(3)$ $X^\mu$ satisfies wave equation
$$(\partial_\sigma^2-\partial_\tau^2)X^\mu=0$$
and the solution is
$$X^\mu(\sigma,\tau)=X_L^\mu(\sigma^+)+X_R^\mu(\sigma^-)$$
which satisfies periodically condition for closed string or boundary condition for open string. From the view of local coordinate systems, it's impossible to construct solution $X^\mu$ on whole the world-sheet $I\times I$ unless the world-sheet is globally conformally flat.
In conclusion, I think physicists' calculation is wrong or they suppose the class of metrics which is globally conformally flat. Is that correct?
Edit2
I found a arxiv that prove the existence of global conformal gauge on $\mathbb{R}^2$. So, $(1)$ is fine for the case of $I\times I$.
I appreciate any idea or reference. I also appreciate it if you tell me how you understood $(1)$ and derived $(3)$ when you studied string theory. Thanks for reading!