I think now I should write a complete answer to my own question according to my own understanding and ofcourse using the other appreciable answers.
To start with let's write down the Boltzmann distribution:$$n_i=N\frac{e^{\frac{-\varepsilon(x_i)}{k_BT}}}{\displaystyle{\sum_{i=1}^∞}e^{\frac{-\varepsilon(x_i)}{k_BT}}}=N\frac{e^{\frac{-\varepsilon(x_i)}{k_BT}}}{Z}\tag{1}$$
Where , $n_i$ is the number of particles in $i$th (micro)state having energy $\varepsilon(x_i)$ , $x$ being the microstate variable .
And , $N$ is the total number of particles in the isolated system.
And , $k_B$ is the Boltzmann constant and $T$ is the absolute temperature.
And, $Z$ is the Partition function.
In other form ($n_i=dN$):$$\frac{dN}{N}=\frac{e^{\frac{-\varepsilon(x_i)}{k_BT}}}{\displaystyle{\sum_{i=1}^∞}e^{\frac{-\varepsilon(x_i)}{k_BT}}}=\frac{e^{\frac{-\varepsilon(x_i)}{k_BT}}}{Z}\tag{2}$$
For average energy ( i.e. Expectation of $E$ ) :$$\bar{E}=\frac{\displaystyle{\sum_{i=1}^∞}\varepsilon(x_i)n_i}{N}=\frac{\displaystyle{\sum_{i=1}^∞}\varepsilon(x_i)dN}{N}\tag{3}$$
So , for finding the the average energy of any sort , we have to find $\frac{dN}{N}$ ( for that case/distribution ) , first.
The quadratic and continuous energy case.
Let's do it for the simple quadratic and continuous energy form , $E=cq²$ ( for example , $E=\frac{1}{2}mv²$ ).
From here, we would be taking $\varepsilon(x_i)=E $ , as the macrostate variable.
Using $eq(2)$ ( multiplying numerator and denominator by $dE$ ) , we get:$$\frac{dN}{N}=\frac{e^{\frac{-E}{k_BT}}dE}{\displaystyle{\sum_{0}^∞}e^{\frac{-E}{k_BT}}dE}=\frac{e^{\frac{-E}{k_BT}}dE}{\displaystyle{\int_0^∞}e^{\frac{-E}{k_BT}}dE}$$
Look! We could use this equation to get the fraction $\frac{dN}{N}$,
the same in any case and hence the average energy in any case
/distribution could be worked out to be $k_BT$ , as in the first
integral of the question.Wait ....what ?
That wrong ! ( looks like , but why ? )
It's because "the Partition function in the denominator is defined (rather derived ) to be the sum over all the microstates ($x_i$) not over the macrostate ($E$)".
Look at the Wikipedia article below:

Let's try to answer the why :
While deriving the Boltzmann distribution through the path of maximizing the entropy ( at equilibrium , which is the Boltzmann distribution all about ) , we encounter the following equation after applying Lagrange multipliers ( $\alpha$ and $\beta$ being constants ) :$$\beta\varepsilon(x_i)+ln(n_i)+\alpha=0$$Which works out to be:$$ln(n_i)=-\alpha-\beta\varepsilon(x_i)$$$$n_i=e^{-\alpha}e^{-\beta\varepsilon(x_i)}$$ To get $e^{-\alpha}$ , we take the sum over all the microstates ($i$) on both sides leaving us with :$$e^{-\alpha}=\frac{\displaystyle{\sum_{x_i}}n_i}{\displaystyle{\sum_{x_i}}e^{-\beta\varepsilon(x_i)}}=\frac{N}{\displaystyle{\sum_{x_i}}e^{-\beta\varepsilon(x_i)}}$$Clearly , putting it in the previous equation we get the Boltzmann distribution as in $eq(1)$ , through which by comparing we get:$$Z=\displaystyle{\sum_{x_i}}e^{-\beta\varepsilon(x_i)}$$Hence , proving that The partition function is the sum over all the microstates as mentioned earlier.
Now , back to our quadratic case and again using the $eq(2)$ but this time by integrating over the microstate variable , which in our case ( $E=cq²$ ) is $q$ , we get:$$\frac{dN}{N}=\frac{e^{\frac{-E}{k_BT}}dq}{\displaystyle{\int_0^∞}e^{\frac{-E}{k_BT}}dq}=\frac{e^{\frac{-cq²}{k_BT}}dq}{\displaystyle{\int_0^∞}e^{\frac{-cq²}{k_BT}}dq}$$Which gives the average energy in the quadratic energy distribution as:$$\bar{E}=\frac{\displaystyle{\sum_{i=1}^∞}\varepsilon(x_i)dN}{N}=\frac{\displaystyle{\int_0^∞}EdN}{N}=\frac{\displaystyle{\int_0^∞}cq²e^{\frac{-cq²}{k_BT}}dq}{\displaystyle{\int_0^∞}e^{\frac{-cq²}{k_BT}}dq}=\frac{k_BT}{2}\tag{4}$$ Which proves the equipartition theorem as in the second integral of the question.
Average energy in Rayleigh - Jeans Radiation Law
In this distribution , the energy only depends on the frequency as $E=hf$ , so the microstate variable in this case is taken as $f$ , giving us :
$$\frac{dN}{N}=\frac{e^{\frac{-E}{k_BT}}df}{\displaystyle{\int_0^∞}e^{\frac{-E}{k_BT}}df}=\frac{e^{\frac{-hf}{k_BT}}df}{\displaystyle{\int_0^∞}e^{\frac{-hf}{k_BT}}df}$$
Hence , the average energy , for this distribution is ( here , the energy is assumed to be continuous even in the quantum system , which was the main reason behind the Ultraviolet Catastrophe ) :
$$\bar{E}=\frac{\displaystyle{\sum_{i=1}^∞}\varepsilon(x_i)dN}{N}=\frac{\displaystyle{\int_0^∞}EdN}{N}=\frac{\displaystyle{\int_0^∞}hfe^{\frac{-hf}{k_BT}}df}{\displaystyle{\int_0^∞}e^{\frac{-hf}{k_BT}}df}=k_BT$$
This could be written in terms of energy as in the first integral in the question as :
$$\bar{E}=\frac{\frac{\displaystyle{\int_0^∞}hfe^{\frac{-hf}{k_BT}}d(hf)}{h}}{\frac{{\displaystyle{\int_0^∞}e^{\frac{-hf}{k_BT}}d(hf)}}{h}}=\frac{\displaystyle{\int_0^∞}Ee^{\frac{-E}{k_BT}}dE}{\displaystyle{\int_0^∞}e^{\frac{-E}{k_BT}}dE}=k_BT$$
Which , is clearly the first integral in the question and describes the average energy for Rayleigh - Jeans Radiation Law, which was later modified by Planck using the quantization of energy.
Actually , we could change the variable from $q$ to $E$ even for the quadratic distribution , noting :
$$dE=d(cq^2)=2cq\cdot dq$$$$dq=\frac{dE}{2cq}=\frac{dE}{2\sqrt{cE}}\tag{5}$$
Then , average energy for Maxwell speed distribution with the integrating variable , $E$ , is ( using $eq(4)$ & $eq(5)$ ):
$$\bar{E}=\frac{\displaystyle{\int_0^∞}cq²e^{\frac{-cq²}{k_BT}}dq}{\displaystyle{\int_0^∞}e^{\frac{-cq²}{k_BT}}dq}=\frac{\displaystyle{\int_0^∞}Ee^{\frac{-E}{k_BT}}\frac{dE}{2\sqrt{cE}}}{\displaystyle{\int_0^∞}e^{\frac{-E}{k_BT}}\frac{dE}{2\sqrt{cE}}}$$Which gives: $$\bar{E}=\frac{\displaystyle{\int_0^∞}\sqrt{E}e^{\frac{-E}{k_BT}}dE}{\displaystyle{\int_0^∞}\frac{e^{\frac{-E}{k_BT}}}{\sqrt{E}}dE}=\frac{k_BT}{2}$$
To summarise :
- Both the equations are in their own correct , according to their use in their respective distribution.
- The general equation for the average energy for any distribution is the $eq(3)$ , based on their $\frac{dN}{N}$ accordingly.
- And , as long as we change the integrating variable in the right way we get the same average energy for a particular distribution, which is obviously fair .