What is the derivation of the formula for finding number of pure and hybrid orbital?
All we are doing is counting orbitals, and these formulas are generalizations of counting the same way that multiplication is generalization of repetitive addition. The derivation is exactly as you present it. For the first formula, we are multiplying the number of hybrid orbitals per carbon atom by the number of carbon atoms. For the second formula, we are multiplying the number of non-hybrid orbitals per carbon atom by the number of carbon atoms and adding the number of hydrogen atoms (since each hydrogen atom only has one orbital that cannot hybridize**).
If you took benzene $\ce{C6H6}$ and counted all of the hybrid orbitals, you would count 18. Each carbon atom is $sp^2$-hybridized, so each has three hybrid orbitals. We could count each individually:
$$1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 = 18$$
Or you could group by each of the six carbon atoms, which eventually simplifies to $3\times 6$
$$(1 + 1 + 1) + (1 + 1 + 1) + (1 + 1 + 1) + (1 + 1 + 1) + (1 + 1 + 1) + (1 + 1 + 1) = 18\\
3 + 3 + 3 + 3 + 3 + 3 = 18\\
3 \times 6 = 18$$
Your formula has some limitations. First, it only works for hydrocarbons (compounds with only carbon and hydrogen atoms), and it assumes all carbon atoms have the same hybridization. Here is a hydrocarbon where the carbon atoms do not all have the same hybridization. This is hex-1-en-5-yne and it has two $sp^3$-hybridized carbon atoms, two $sp^2$-hybridized carbon atoms, and two $sp$-hybridized carbon atoms.

Your formula could be extended to:
$$N_{\mathrm{HO}} = 2n_{sp} + 3n_{sp^2} + 4n_{sp^3}$$
Where $N_\mathrm{HO}$ is the number of hybrid orbitals, $n_{sp}$ is the number of $sp$-hybridized carbon atoms, $n_{sp^2}$ is the number of $sp^2$-hybridized carbon atoms, and $n_{sp^3}$ is the number of $sp^3$-hybridized carbon atoms. For hex-1-en-5-yne, we could count:
$$N_\mathrm{HO} = 2\times 2 + 3\times 2 + 4\times 2 = 18$$
There is a more general formula for hydrocarbons. Let's look at it this way. Each carbon atom has four orbitals (either hybridized or non-hybridized). If there are no $\pi$-bonds, then the number of hybrid orbitals is four times the number of carbon atoms. Each $\pi$-bond requires to non-hybridized $p$-obitals, so each $\pi$-bond reduces the number of hybrid orbitals by 2. Here is a general formula for hydrocarbons:
$$N_\mathrm{HO} = 4n_\mathrm{C} - 2n_\pi$$
Here $n_\mathrm{C}$ is the number of carbon atoms and $n_\pi$ is the number of $\pi-bonds$. For benzene, $n_\ce{C} = 6$ and $n_\pi = 3$, so
$$N_\mathrm{HO} = 4\times 6 - 2 \times 3 = 24 - 6 = 18$$
For hex-1-en-5-yne, we have the same number of carbon atoms and $\pi$-bonds, so we get the same result. For the number of non-hybridized orbitals ($N_\mathrm{NHO}$), we have a general formula as well. Each hydrogen atom contributes one non-hybridized orbital ($n_\ce{H}$), and each $\pi$-bond contributes two.
$$ N_\mathrm{NHO} = n_\ce{H} + 2n_\pi$$
For benzene and hex-1-en-5-yene, $n_\ce{H} = 6$ and $n_\pi = 3$, so
$$ N_\mathrm{NHO} = 6 + 2\times 3 = 12$$
This is the same as your second formula.
** I expect one of my physical/theoretical chemist colleagues to come along and inform us that under certain circumstances, hydrogen atoms may in fact act as if they have hybrid orbitals, but for most organic compounds we can ignore this behavior.