You are correct that for resistors power rating is one of the big factors affecting size, but it is not the only one. Voltage rating is also important to be aware of.
If you are running a circuit at 100V for example, you wouldn't use an 0402 resistor because the breakdown voltage of 0402 resistors is generally much lower than this (i.e. it will short through if you put too high a voltage across it). The larger the package, typically the larger the voltage rating.
In the case of capacitance there are several reasons for choosing a larger package over a smaller one. For one larger packages typically allow for higher capacitance because there is more physical space - you couldn't for example get a decent 10uF cap in an 0402 package.
If we assume you compare two capacitors of the same value (e.g. two 100nF caps), the larger ones will again typically have a higher rated working voltage. This is beneficial for two reasons. The first is obvious, and that is if you need a higher working voltage for your circuit - you wouldn't choose an 0402 rated at 10V if you need to run a circuit at 25V. The second is more subtle and I'll come to it in a moment.
A third reason is that there are different dielectrics. X7R is typically the best performer in terms of stability and has better DC performance. X5R is less good in that regard. Generally X7R capacitors are physically larger for the same voltage/capacitance ratings than X5R capacitors.
Furthermore, if you put an MLCC in a circuit charged to a DC level such as with a decoupling cap, you actually want to pick a rated voltage much higher than your working voltage. The reason for this is that the rated capacitance of an MLCC is heavily dependent on DC voltage.
A 10V MLCC might have a capacitance 50% lower than rated when running at 5V DC whereas a 25V MLCC might be only 10% lower than rated for the same running voltage. You can for example get a 100nF 0201 6.3V MLCC, but if you try to use that to decouple a 5V power line, you might find that the actual capacitance is only 10nF or less! As such, if you have the space, you typically want to go with a larger package with a higher rated voltage if you have the space