The concept of $\text{WACC}$ seems pretty straightforward... it is a weighted average percentage, calculated in principle as equation $(2)$ in the question shows. If we have two sources of financing each demanding a different interest rate and with given percentage contribution each to the total funds we want to borrow, then what would be the single interest rate that would lead to the same total interest cost, if we borrowed the sum of funds from some third source? And this easily generalizes to $n$ sources of financing.
The concept stops being so straightforward the moment one realizes that the property rights and the transaction clauses characterizing the "cost of equity funds" and the "cost of debt funds" respectively are totally different (and this is why this is the first grand partition), and also, that "the future won't necessarily repeat the past".
Related to Debt funds, Debt owners have the full power of the Law behind them to seek payment of interest and principal, against the company's assets. Also, the interest rate is specifically agreed to a certain level, and even if there are provisions that may make it variable, these usually create few scenarios one would need to evaluate. So calculating the (unitary) "cost of debt" appears relatively transparent and certain.But: a distinction has to be made related to past "cost of debt" and the prospective one: the current debts of the company may have a certain interest rate agreed upon, but the interest rate that the company must pay in order to get more debt may be different. This essentially tends to make the concept a marginal weighted average, and the company must conduct a market search in order to see what interest rates prospective debt owners would demand for new debt. But for an outsider, this information is usually not available -he has to rely on published data on debt and interest rates agreed in the past from the company's financial statements.
Turning to Equity funds, the equity holder has no power whatsoever over the company to seek payment of any rate of return, or of his funds (in cases of fraud, gross negligence etc, the equity holder may demand compensation from the persons that were involved, managers etc, but not from the company as a legal entity). In other words, there is no "legally committed" interest rate here, nor "obligatory" rate of return (funds that appear as equity but are characterized by such clauses are not considered equity but debt, under both Finance practices and Accounting principles). So here the (unitary) "cost of equity" is the rate of return that prospective equity holders would want to be persuaded that the company will generate using their funds. In two-steps: I want $\text{xx}$% rate of return, and in order to invest my funds to you as equity, you have to "persuade" me that you will manage to pay me that rate of return. Persuade how? By past performance, convincing analysis of future prospects, and charm.
So how do we calculate this component of $\text{WACC}$? We usually look at how the company is performing relative to its sector. Why the sector and not the whole market, has to do with increased risk that correlates with inexperience: investors that for some historical reasons have concentrated their investments in a sector, will be in a better position to judge the validity of prospective projects in this sector, than to some other they don't have a clue about. So some combination of company/sector rates of return provides an estimation of the (unitary) cost of equity (this again brings in the distinction between a "historical $\text{WACC}$" against a "marginal" $\text{WACC}$).
And finally, how do we calculate the relative weights of the two sources? Again, time series data from the company's financial statements can show how this mix has evolved over the years for the company.