How Random Forests can be used for regression?
The key is in choosing the split function of the decision tree. In classification, the data is split according to a certain homogeneity metric. On the other hand, for a regression tree, a regression model is fit to the dependent variable, for each of the independent variables. Then, the data is split at multiple points and the SSD value is evaluated. The best split is chosen for the dimension (variable) giving the minimum error. The node is then split at this point. The splitting is again recursive.

Finally, each leaf stores a distribution for the continuous output variable/s. In the testing phase, the responses are averaged.