I work through an example of deriving the mean and variance of a continuous probability distribution. I assume a basic knowledge of integral calculus.

I work through an example of deriving the mean and variance of a continuous probability distribution. I assume a basic knowledge of integral calculus.
I don’t understand why mean is defined in such way. In statistics when a data is given we define mean by sum of the data given divided by no. if values but in discrete probability distribution and continuous probability distribution we define mean by multiplying random variable with respective probabilities So why is that