Recall that power is energy over time, and 1 watt = 1 joule/sec. Power is commonly calculated in simple circuits as P (power, Watts) = V(voltage, V)*I (generated current, A). The power rating of a component is its ability to dissipate the heat generated by the power flowing through it. Any component must be able to dissipate the heat energy generated while in use in a circuit, or else it will fail. Resistors can generate a lot of heat due to their purpose of resisting the flow of current; the energy they stop from flowing in the circuit must be converted into heat.
If the power being dissipated exceeds the power rating of the resistor, it will fail, and the circuit will most likely stop working as well. Part of the selection process will be making sure you use a resistor with a power rating well above the expected power dissipation capability. This will ensure that it can handle variations in the power in the circuit as well as helping with the resistors reliability.
Another reason to select a resistor with a power dissipation capability much greater than needed is tolerance. All components will give +/- the voltage or current they are rated for, and then putting many components in a circuit together can lead to unexpected variations. A resistor can have tolerances in it’s Ohm rating of 10%, 5%, 1% (and more) for example. When that resistance interacts with the circuit, the result could be power dissipation requirements could similarly be 1-10% higher (or lower) than expected.
Finally, a common guideline for selecting a resistor based on its power-dissipation capability is to choose one with twice the expected load. That way the resistor will be able to handle expected as well as unexpected loads when something goes wrong, and ensure maximum reliability in normal use as time goes by.
Putting these together:
1) Calculate the power you expect to dissipate
2) Consider how the tolerances you select will act in your circuit
3) Commonly accepted practice is to simply double the calculated power