In quantum teleportation, why does measuring entanglement not destroy the whole state?

In quantum teleportation, we have three qubits. Sender, receiver and ancillary. First, we entangle the ancillary and target qubit. Next, we entangle ancillary and sender qubits. Now, the whole system of three states is entangled together.

Next step is to measure sender and ancillary qubit and based on that we apply controlled x and controlled z gate in the target qubit.

So, my question is when we measure sender and ancillary qubit, should it not destroy the whole quantum system including the target qubit as everything is entangled together and why whole system is not collapsing?

The measurement doesn't "destroy the whole quantum system", because you're not measuring the whole quantum system. You're only measuring two of the three systems. It's like saying: if you have maximally entangled qubits, $$|00\rangle+|11\rangle$$ and you measure the first one in the computational basis, $$\{|0\rangle,|1\rangle\}$$, the second one is not "destroyed", but rather collapses on the same state you observed measuring the first qubit. If you measured $$|0\rangle$$, you know the second qubit is also $$|0\rangle$$, etc. If you instead measure the first qubit in the $$X$$ eigenbasis, $$\{|+\rangle,|-\rangle\}$$, then finding $$|+\rangle$$ collapses the second qubit to $$|+\rangle$$, etc.

You can think of teleportation as working along the same principles. Except the measurement you're performing on the first qubit depends on the state $$|\psi\rangle$$ you're trying to teleport. The trick of doing a Bell measurement on two qubits on the sender's side achieves precisely this. Except instead of the sender performing a standard two-outcome projective measurement on their part of the entangled state, they perform a four-outcome POVM which depends on the state $$|\psi\rangle$$ to send over.

Formally, you can see it because the entire procedure on the sender side amounts to performing the POVM $$\boldsymbol\mu$$ such that: $$\operatorname{tr}(\mu_i \rho)=\langle \Psi_i| \mathbb{P}_\psi\otimes \rho|\Psi_i\rangle, \qquad \mathbb{P}_\psi\equiv|\psi\rangle\!\langle\psi|,$$ with $$|\Psi_i\rangle$$, $$i=1,2,3,4$$ the four Bell states, and $$\rho$$ the reduced state on the sender's side (yes, in the entanglement protocol this reduced state is just $$I/2$$, but here I'm describing the measurement procedure in isolation, I don't care what $$\rho$$ is; the measurement will then actually be performed on the entangled state, not actually just on the reduced state). Note that we can always write the Bell states as $$|\Psi_i\rangle=(U_i\otimes I)|m\rangle$$ with $$|m\rangle\equiv\frac{|00\rangle+|11\rangle}{\sqrt2}$$ and $$U_i\in\{I,X,Y,Z\}$$ the Pauli gates. It follows from some simple manipulation that $$\mu_i = \operatorname{tr}_1[(\mathbb{P}_\psi\otimes I)\mathbb{P}_{\Psi_i}] \equiv (\langle\psi|\otimes I)|\Psi_i\rangle\!\langle\Psi_i|(|\psi\rangle\otimes I) = \frac12 \mathbb{P}(U_i^T|\bar\psi\rangle).$$ So what happens is: the sender gets the outcome $$i$$ from their four-outcome measurement, which collapses their state on $$U_i^T|\bar\psi\rangle$$. But projecting one part of $$|00\rangle+|11\rangle$$ on some $$|\phi\rangle$$ gives you $$|\bar\phi\rangle$$ on the other side, as follows from $$(\langle\phi|\otimes I)(|00\rangle+|11\rangle) = |\bar\phi\rangle.$$ In other words, when the sender gets the $$i$$-th outcome, the receiver's state collapses to $$\bar U_i|\psi\rangle$$. Once they know which $$i$$ was measured, it is therefore easy for the receiver to correct away the $$\bar U_i$$ operation and end up with $$|\psi\rangle$$.

Good question, to answer it you can (and should) of course describe the system mathematically, but the problem is that the description never specifies what "classical transport" exactly does. It could be, for instance (to make it really "classical") encoding the two transported bits by carving $$0$$ or $$1$$ into two 100-ton granite blocks.

The simplest toy model is to say that classical transport means that the phase difference between the $$|0\rangle$$ and $$|1\rangle$$ components of a transported qubit is lost (by adding a very large, uncontrolled amount to the phase difference, caused by environment influences). This means that for an initial qubit with magnitude ratio and phase difference, it will only preserve the magnitude ratio. Classical transport preserves one real number of information from the two that are present in a qubit. That's why you need to transport two of them to transport the information for one single "teleported" qubit. In picture:

where we have two $$z$$-rotations over (very big) angles $$\phi_1, \phi_2$$. If you think this picture is too simple you can of course introduce more qubits which do some subsequent transfer of the two that are to be classically transported, but you will see that this does not change the picture: phase coherence is lost, magnitude ratio of the components is kept. Or stated differently, the reduced density matrix for the classically transported subsystem will keep unchanged diagonal elements. As is known, the environment cannot undo entanglement, not even for 100-ton granite blocks, it can only give decoherence of the phase.

The computation in this picture (in 8-dimensional space if we do not further complicate this toy model) will then show you that the result for the teleported qubit is independent of the two random angles $$\phi_1, \phi_2$$. You can do it in Mathematica or some other tool and see how they drop out of the result. That's all there is to it!